Follow

Keep Up to Date with the Most Important News

By pressing the Subscribe button, you confirm that you have read and are agreeing to our Privacy Policy and Terms of Use
Contact

Why am I getting TimeoutException in Selenium with Python?

Just started learning Selenium with Python. And no matter how much I change the WebDriverWait, it’s still giving me the TimeoutException.

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


url = 'https://bbrauncareers-bbraun.icims.com/jobs/search?ss=1&searchRelation=keyword_all'
driver = webdriver.Chrome()
driver.implicitly_wait(30)
driver.get(url)
wait = WebDriverWait(driver, 30)

title = wait.until(EC.visibility_of_element_located((By.CSS_SELECTOR, 'div.description')))


print(title)

The page loads fully on driver.get(url), but it doesn’t seem to want to find the title. I tried changing the css selector to anything else on the page, and it’s still the same. What am I doing wrong here? Thank you!

MEDevel.com: Open-source for Healthcare and Education

Collecting and validating open-source software for healthcare, education, enterprise, development, medical imaging, medical records, and digital pathology.

Visit Medevel

>Solution :

There is an IFRAME which is wrapping the desired element inside. You need to switch into the IFRAME first, then you need to perform the action you want on the desired element.

Refer the below code:

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

driver = webdriver.Chrome()
driver.maximize_window()
driver.get("https://bbrauncareers-bbraun.icims.com/jobs/search?ss=1&searchRelation=keyword_all")
wait = WebDriverWait(driver, 15)

# below line will switch into the IFRAME
wait.until(EC.frame_to_be_available_and_switch_to_it((By.ID, "icims_content_iframe")))

title = wait.until(EC.visibility_of_element_located((By.XPATH, "(//div[contains(@class,'description')])[1]")))
print(title.text)

# Below line will come out of IFRME
driver.switch_to.default_content()

Console output:

About B. Braun    B. Braun Medical Inc., a leader in infusion therapy and pain management, develops, manufactures, and markets innovative medical products and services to the healthcare industry. Other key product areas include nutrition, pharmacy admixture and compounding, ostomy and wound care, and dialysis. The company is committed to eliminating preventable treatment errors and enhancing patient, clinician and environmental safety. B. Braun Medical is headquartered in Bethlehem, Pa., and is part of the B. Braun Group of Companies in the U.S., which includes B. Braun Interventional Systems, Aesculap® and CAPS®.   Globally, the B. Braun Group of Companies employs more than 61,000 employees in 64 countries. Guided by its Sharing Expertise® philosophy, B. Braun continuously exchanges knowledge with customers, partners and clinicians to address the critical issues of improving care and lowering costs. To learn more about B. Braun Medical, visit www.BBraunUSA.com.  

Process finished with exit code 0
Add a comment

Leave a Reply

Keep Up to Date with the Most Important News

By pressing the Subscribe button, you confirm that you have read and are agreeing to our Privacy Policy and Terms of Use

Discover more from Dev solutions

Subscribe now to keep reading and get access to the full archive.

Continue reading