0

Problem: I'm building a software using selenium which:

  1. goes to a web page (a search page).
  2. searches a term
  3. the items get added to the search page dynamically
  4. clicks on the first item
  5. a pop up body happens with more info on that item which is a dynamic html added to the source
  6. saves the info
  7. Now I want to get out of that pop up, by clicking on an exit <button> using driver.find_element_*can't find the element without refreshing the page, because it was added to the page.

I've tried:

  1. first try
WebDriverWait(driver,10).until(EC.element_to_be_clickable((By.CLASS_NAME, 'the class of the element')))
and
WebDriverWait(driver, 10).until(EC.presence_of_element_located((By.CLASS_NAME, 'class name')))
  1. second try :
driver.page_source

3.second try : combination of both

WebDriverWait(driver,10).until(EC.element_to_be_clickable(By.CLASS_NAME, 'the class of the element'))
driver.page_source

In the case of wait().until(); I don't find the button element even though I can see it in the browser, till I get timed out.

Thank you in advanced.

EDIT: the website is upwork.com job search

5
  • Can you provide us with the website in question? It could be that your locator is incorrect. Also it would be nice to see some actual code instead of empty functions calls. Commented Oct 15, 2020 at 22:35
  • "can't find the element without refreshing the page, because it was added to the page." That is incorrect. If the DOM is updated via javascript, you want to use a webdriverwait with an expected condition so that Selenium doesn't check the DOM during or before that update occurs. (an implicit wait would also work but isn't targetted to a specific condition.) Commented Oct 15, 2020 at 22:42
  • @AlfaQ I've edited the question, what is the solution? Commented Oct 15, 2020 at 22:52
  • @pcalkins I tried WebDriverWait, also tried time.sleep() non worked. Commented Oct 15, 2020 at 22:53
  • @AlfaQ what happened? Commented Oct 16, 2020 at 2:10

0

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.