Unable to find element on closed window in Python using Selenium -
def check_text(browser, sitename): browser.get(sitename) try: text = browser.find_element_by_class_name("text_content").text if "foo" in text: print("ok") else: print("not ok") except nosuchelementexception: print("no such elem") def check_internet_explorer(): sitename="*foo site*" caps = desiredcapabilities.internetexplorer caps['ignoreprotectedmodesettings'] = true ie = webdriver.ie(capabilities=caps) check_text(ie, sitename)
this code works fine on windows 10. when try run on windows 7, webpage loads error: "unable find element on closed window" looked error online , it's internet explorer protected mode. tried adding "ignore protect mode settings" capability, same error. can do?
here answer question:
when work selenium 3.4.0
, iedriverserver 3.4.0
ie(v 10/11)
error: "unable find element on closed window" may occur due several limitations of internet explorer
, iedriverserver.exe
. prevent errors can explicitly set nativeevents
, requirewindowfocus
true
through desiredcapabilities
class follows:
caps = desiredcapabilities.internetexplorer caps['ignoreprotectedmodesettings'] = true caps['nativeevents'] = true caps['ignorezoomsetting'] = true caps['requirewindowfocus'] = true caps['internetexplorerdriver.introduce_flakiness_by_ignoring_security_domains'] = true ie = webdriver.ie(capabilities=caps)
as facing issue on
windows 7
documentation mentions following points: on ie 7 or higher on windows vista or windows 7, must set protected mode settings each zone same value. value can on or off, long same every zone. set protected mode settings, choose "internet options..." tools menu, , click on security tab. each zone, there check box @ bottom of tab labeled "enable protected mode".
you can find more documentation these facts in link.
let me know if answers question.
Comments
Post a Comment