Selenium Internet Explorer 8缓存问题

gor*_*sbm 5 python selenium internet-explorer

当我在Win XP Internet Explorer 8上运行我的Selenium测试时,测试没有重新开始.它将使用之前运行的cookie /缓存启动测试.当我在Firefox中运行测试时,这不会发生.有人有解决方法吗?最好在Python
中我的一些想法:
- 在tearDownClass中运行一个脚本,删除所有临时文件:C:\ Documents and Settings\Owner\Local Settings\Temporary Internet Files
- 而不是"*iehta"作为我设置的浏览器它到Internet Explorer私有模式"*自定义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()
Run Code Online (Sandbox Code Playgroud)

sha*_*p00 1

您可以使用sel.delete_all_visible_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)
Run Code Online (Sandbox Code Playgroud)

请参阅此博客文章了解更多信息。