Message: element not interactable on accessing a tag python

后端 未结 2 1456
野趣味
野趣味 2021-01-27 01:48

I am trying to access the sign in button on the url as shown in the code below. I have verified the content of the url as well as the href. They are both consistent with what ap

相关标签:
2条回答
  • 2021-01-27 02:13

    To click on the element with text as Sign In you need to induce WebDriverWait for the element_to_be_clickable() and you can use either of the following Locator Strategies:

    • Using CSS_SELECTOR:

      WebDriverWait(browser, 20).until(EC.element_to_be_clickable((By.CSS_SELECTOR, "a.main-navigation__navbar span"))).click()
      
    • Using XPATH:

      WebDriverWait(browser, 20).until(EC.element_to_be_clickable((By.XPATH, "//a[@class='main-navigation__navbar ']//span"))).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
      
    0 讨论(0)
  • 2021-01-27 02:17

    To click on Sign In link Induce WebDriverWait() and element_to_be_clickable() and following css selector.

    WebDriverWait(browser,10).until(EC.element_to_be_clickable((By.CSS_SELECTOR,"a.main-navigation__navbar>.main-navigation__navbar-text"))).click()
    

    Or following xpath.

    WebDriverWait(browser,5).until(EC.element_to_be_clickable((By.XPATH,"//span[text()='Sign In']"))).click()
    

    You need to import below libraries.

    from selenium.webdriver.common.by import By
    from selenium.webdriver.support.ui import WebDriverWait
    from selenium.webdriver.support import expected_conditions as EC
    
    0 讨论(0)
提交回复
热议问题