Home > Software design >  I am having trouble clicking the signup button on a reddit sign up page with selenium using python
I am having trouble clicking the signup button on a reddit sign up page with selenium using python

Time:06-02

I am trying to submit a form to create a new reddit account using selenium at https://www.reddit.com/reddits/login/ . I am new to using selenium and web scraping in general and need some help selecting and ultimately clicking the sign up button on this webpage after all the details have been entered in. I have tried to select it using

submit = browser.find_element(By.CSS_SELECTOR("//*[@id="register form"]/div[7]/button")).text

along with trying to grab it through its xpath which is

//*[@id="register-form"]/div[7]/button

but am having no luck. The farthest I am able to get is having it say a 'str' object is not callable using Selenium through Python as an error message or it will say element not found. Any help would or guidance in the right direction would be greatly appreciated.

Sorry this is also my first question on stack overflow as well I apologize in advance.

Picture of the Button I am trying to click on with selenium

Sign Up Button Picture

CodePudding user response:

The CSS Selector for that submit button would be:

"#register-form button"

You can verify from the console of a web browser by calling:

document.querySelector("#register-form button")

CodePudding user response:

XPATH worked for me:

url = driver.find_element(By.XPATH , '//*[@id="register-form"]/div[7]/button')

url.click()

  • Related