NoSuchElementException, Selenium unable to locate element

前端 未结 3 723
滥情空心
滥情空心 2020-11-21 06:09

i would like to find my TextField in selenium, but i dont know how (i use sellenium for the first time).

I tried:

 driver.findElement(By.id(\"originT         


        
3条回答
  •  走了就别回头了
    2020-11-21 06:30

    Your code is correct, I suspect the issue caused the page not complete load when you find the element.

    Try add a long sleep before find element, if adding sleep worked, change sleep to wait.

    Here is the code, It means waiting 10s if the element isn’t present:

    element = WebDriverWait(driver, 10).until(
        EC.presence_of_element_located((By.ID, "originTextField"))
    )
    

提交回复
热议问题