Solution 1 :

You’re not going to be able to attach to an existing browser session.

A solution that I’ve used in the past is to halt the script execution until a key is pressed so I can manually login and get to the expected page.

In Python 3 use input():

input("Press Enter to continue...")

In Python 2 use raw_input():

raw_input("Press Enter to continue...")

Problem :

I’m very new to python and was trying to learn how to make a script that clicks certain buttons on a website.

From my research, it seems that Selenium is a great option. This is the code I’ve written thus far:

from selenium import webdriver
import time

browser = webdriver.Chrome()
browser.get('URL')
time.sleep(0.7)

atc = browser.find_element_by_xpath('XPATH')
atc.click()
time.sleep(0.3)

check = browser.find_element_by_xpath('XPATH')
check.click()

The program runs fine, and I’ve removed some specific code

I need Selenium to boot up Chrome but not a new instance of Chrome. I need the script to work on a specific website that needs to be already logged in, so basically through my Chrome Profile.

Question:
Is there a way to get around this problem? From what I know (which is little) the problem arrises from the webdriver.Chrome

Is there a way to bypass the webdriver.Chrome and use just the find_element_by_xpath? Thats really the only reason I need to use this. I don’t need to boot up a link from Selenium, just have the script find a button and click it

Thank you!

Edit:
Would a simple solution be to have my login already in place and have the script run on a separate window so it can bypass the “Please Sign In” page?

Comments

Comment posted by LM1234

This could actually work! How would I write the script to start if I press “Return”?

Comment posted by scilence

It will just continue executing the code that’s placed after that line.

By

Leave a Reply

Your email address will not be published. Required fields are marked *