ogul ogul - 2 months ago 8
Python Question

Selenium Chrome, Python. Couldn't find the button on the website

I am newly learning how to work with Webdriver and while I am playing with it on Eventbrite website it couldn't find the create event button while it is there(I can click it). I try lots of different things to locate button like XPath, link_text, class but they didn't work. Here is the code I am working with :

driver = self.driver
driver.get("https://www.eventbrite.com/")
driver.find_element_by_xpath("(//a[contains(text(),'Log in')])[2]").click()

driver.find_element_by_id("login-email").clear()
driver.find_element_by_id("login-email").send_keys("email")
driver.find_element_by_id("login-password").clear()
driver.find_element_by_id("login-password").send_keys("password")
driver.find_element_by_id("remember_me").click()
driver.find_element_by_xpath("//input[@value='Log in']").click()
time.sleep(2)
driver.find_element_by_link_text("Create Event").click()


Can anyone please help me with this ?

Answer

If I'm understanding your question right, the last line of your example ("Create Event") is the one that doesn't work? I can say that if I use a css selector, I can click that button. (I also tend to find css selectors are easier to work with)

driver = self.driver
driver.get("https://www.eventbrite.com/")
driver.find_element_by_xpath("(//a[contains(text(),'Log in')])[2]").click()

driver.find_element_by_id("login-email").clear()
driver.find_element_by_id("login-email").send_keys("email")
driver.find_element_by_id("login-password").clear()
driver.find_element_by_id("login-password").send_keys("password")
driver.find_element_by_id("remember_me").click()
driver.find_element_by_xpath("//input[@value='Log in']").click()
time.sleep(2)
driver.find_element_by_css_selector("div.l-mar-top-3 a.js-organizer-cta-btn").click()