0
  1. The problem: I'm trying to click this href here:

enter image description here

  1. Fail attempts: I tried to use these to no avail

    driver.find_element_by_link_text('Join').click()
    driver.find_element_by_partial_link_text('href').click()
    
3
  • In the image, there is a space before Join. Commented Sep 18, 2020 at 2:14
  • Thank you, I didn't realize that Commented Sep 18, 2020 at 19:00
  • @IsaiahLowe always copy the text even if you are spelling bee champ ! Commented Sep 18, 2020 at 20:56

2 Answers 2

1

You can use xpath instead of link text.

driver.find_element_by_xpath('//a[contains(text(), "John"]').click()

Or add space in front of John.

driver.find_element_by_link_text(' Join').click()
Sign up to request clarification or add additional context in comments.

2 Comments

Where I put the xpath for ** driver.find_element_by_xpath('//a[contains(text(), "John"]').click() **
Replace this line driver.find_element_by_link_text('Join').click()
0

To click on the element with text as Join you can use either of the following Locator Strategies:

  • Using partial_link_text:

    driver.find_element_by_partial_link_text("Join").click()
    
  • Using xpath:

    driver.find_element_by_xpath("//a[contains(., 'Join')]").click()
    

Ideally, to click on the element you need to induce WebDriverWait for the element_to_be_clickable() and you can use either of the following Locator Strategies:

  • Using PARTIAL_LINK_TEXT:

    WebDriverWait(driver, 20).until(EC.element_to_be_clickable((By.PARTIAL_LINK_TEXT, "Join"))).click()
    
  • Using XPATH:

    WebDriverWait(driver, 20).until(EC.element_to_be_clickable((By.XPATH, "//a[contains(., 'Join')]"))).click()
    
  • Note: You have to add the following imports :

    from selenium.webdriver.support.ui import WebDriverWait
    from selenium.webdriver.common.by import By
    from selenium.webdriver.support import expected_conditions as EC
    

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.