from selenium import webdriver
driver = webdriver.Firefox()
driver.get("https://my.gumtree.com/login")
driver.find_element_by_name("username").send_keys(email)
driver.find_element_by_id("existingUser").click()
driver.find_element_by_id("fld-password").send_keys(password)
driver.find_element_by_xpath("//*[contains(text(), 'Continue')]").click() # works
driver.get("https://my.gumtree.com/postad")
driver.find_elements_by_xpath("//*[text()='For Sale']")[-1].click() # this now works, thanks
# driver.find_element_by_xpath("//*[contains(@span,'Appliances']").click() # this worked but I need the next line instead
driver.find_element_by_xpath("//span[text()[normalize-space()='Phones, Mobile Phones & Telecoms']]").click() # this does not work
driver.find_element_by_xpath("//span[text()[normalize-space()='Phones, Mobile Phones & Telecoms']]").click() # this does not work either
driver.find_element_by_xpath("//span[text()[normalize-space()='Mobile Phones']]").click()
driver.find_element_by_xpath("//span[text()[normalize-space()='Other']]").click()
Я пытаюсь нажать на текстовые ссылки, но это не работает: [code]from selenium import webdriver driver = webdriver.Firefox() driver.get("https://my.gumtree.com/login") driver.find_element_by_name("username").send_keys(email) driver.find_element_by_id("existingUser").click() driver.find_element_by_id("fld-password").send_keys(password) driver.find_element_by_xpath("//*[contains(text(), 'Continue')]").click() # works
driver.get("https://my.gumtree.com/postad") driver.find_elements_by_xpath("//*[text()='For Sale']")[-1].click() # this now works, thanks # driver.find_element_by_xpath("//*[contains(@span,'Appliances']").click() # this worked but I need the next line instead driver.find_element_by_xpath("//span[text()[normalize-space()='Phones, Mobile Phones & Telecoms']]").click() # this does not work driver.find_element_by_xpath("//span[text()[normalize-space()='Phones, Mobile Phones & Telecoms']]").click() # this does not work either driver.find_element_by_xpath("//span[text()[normalize-space()='Mobile Phones']]").click() driver.find_element_by_xpath("//span[text()[normalize-space()='Other']]").click() [/code] HTML: [code][*]