Python Selenium Internet Explorer 8缓存问题
当我在Win XP Internet Explorer 8上运行Selenium测试时,测试不会重新开始。它将使用上一次运行的cookies/cache启动测试。在Firefox中运行测试时不会发生这种情况。 有人对此有解决办法吗?最好使用PythonPython Selenium Internet Explorer 8缓存问题,python,internet-explorer,selenium,Python,Internet Explorer,Selenium,当我在Win XP Internet Explorer 8上运行Selenium测试时,测试不会重新开始。它将使用上一次运行的cookies/cache启动测试。在Firefox中运行测试时不会发生这种情况。 有人对此有解决办法吗?最好使用Python 我的一些想法: -在tearDownClass中运行脚本,删除C:\Documents and Settings\Owner\Local Settings\temporary Internet files中的所有临时文件 -我将浏览器设置为In
我的一些想法:
-在tearDownClass中运行脚本,删除C:\Documents and Settings\Owner\Local Settings\temporary Internet files中的所有临时文件
-我将浏览器设置为Internet Explorer专用模式,而不是“*iehta”*“自定义C:\Program Files\Internet Explorer\iexplore.exe-private”(-由于我的语法被禁用而无法工作?” 多谢各位
import unittest, inspect, time, re, os
from selenium import selenium
class TESTVerifications(unittest.TestCase):
@classmethod
def setUpClass(self):
self.selenium = selenium("localhost", 4444, "*iehta", "https://workflowy.com/")
self.selenium.start()
self.selenium.set_timeout("60000")
print("setUpClass")
self.selenium.window_maximize()
self.selenium.open("/")
def setUp(self):
self.verificationErrors = []
def test_login_6(self):
sel = self.selenium
sel.open("/")
sel.type("css=input[id='id_username']",'test+abc010@workflowy.com' )
sel.type("css=input[id='id_password']",'password')
sel.click("css=form[id='login'] > input.submit")
sel.wait_for_page_to_load("60000")
self.failUnless(sel.is_element_present("id=logout"))
def tearDown(self):
#self.selenium.stop()
self.assertEqual([], self.verificationErrors,"Results: " + str(self.verificationErrors))
@classmethod
def tearDownClass(self):
self.selenium.stop()
print("tearDownClass")
if __name__ == "__main__":
unittest.main()
您可以使用
sel.delete\u all\u visible\u cookies()
,这将删除当前域创建的任何cookie。如果您有多个域,则可以使用以下选项:
def clean_history(sel, domains):
temp = sel.get_location()
for domain in domains:
sel.open(domain)
sel.delete_all_visible_cookies()
sel.open(temp)
有关更多信息,请参阅