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 just fine on windows 10. When I try to run it on windows 7, the webpage loads but I get this error: "Unable to find element on closed window" I looked for this error online and it's something about internet explorer protected mode. I tried adding the "ignore protect mode settings" capability, but I get the same error. What can I do?