1

I'm trying to click a the element with text as I don't have the telephone on this website.

So I find the element with inspect. here is the element in html:

<span class="toggle-link link_has-no-phone" role="button">I&nbsp;don't have a&nbsp;telephone number</span>

In my nonfunctional code i wrote this:

r = driver.find_element_by_xpath("//*[@id='root']/div/div[2]/div/main/div/div/div/form/div[3]/div/div[2]/div/span")
r.click

The button is never clicked and nothing happens i get no error and i can't click it any help would be appreciated.

1
  • 1
    Shouldn't it be r.click() instead of r.click? Commented Mar 10, 2019 at 19:05

3 Answers 3

1

You can use css selector below to get span:

r = driver.find_element_by_css_selector(".link_has-no-phone")
r.click()
Sign up to request clarification or add additional context in comments.

Comments

1
r = driver.find_element_by_xpath("//*[@id='root']/div/div[2]/div/main/div/div/div/form/div[3]/div/div[2]/div/span")
r.click()

You just forgot the parenthesis

Comments

0

To click on the element with text as I don't have a telephone number you can use either of the Locator Strategies:

  • css_selector:

    driver.find_element_by_css_selector("span.toggle-link.link_has-no-phone").click()
    
  • xpath:

    driver.find_element_by_xpath("//span[@class='toggle-link link_has-no-phone']").click()
    

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.