1

I want to check to see if a certain window is open and if it is than to proceed to log out however if it is not than to open up the widget and then logout out.

The widget is inside of another frame. I don't want to have to switch frames just to see if the widget is open if I do not have to.

My Code:

window=driver.find_element_by_id("DR44")
if window.is_displayed():
    userdropdown=driver.find_element_by_id("Menu").click()
    logout=driver.find_element_by_id("df456").click()
else:
     LaunchMenu=driver.find_element_by_id("launch").click()
     bvWidget=driver.find_element_by_id("54353sfd").click()
     launch= driver.find_element_by_id("3rfs").click()
     userdropdown=driver.find_element_by_id("userMdfd243l").click()
     logout=driver.find_element_by_id("efdf343").click()

My error: Unable to locate element

I want to check to see if the title of the widget is found on the page if so then proceed to log out and if not open up the widget and then log out.

1 Answer 1

1

You can not interact any element inside an iframe if you dont switch to iframe. First switch to iframe by driver.switch_to_frame() and you also dont need to assign an element to variable to click to. see below:

driver.switch_to_frame(iframe) 

if driver.find_element_by_id("DR44").is_displayed():
    driver.find_element_by_id("Menu").click()
    driver.find_element_by_id("df456").click()
else:
    driver.find_element_by_id("launch").click()
    driver.find_element_by_id("54353sfd").click()
    driver.find_element_by_id("3rfs").click()
    driver.find_element_by_id("userMdfd243l").click()
    driver.find_element_by_id("efdf343").click()

To be noted: iframe is a list of iframe ids

Sign up to request clarification or add additional context in comments.

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.