您的位置:首页 > 编程语言 > Python开发

python3.5+selenium打开chrome浏览器,去掉ignore-certificate-errors提示

2015-12-17 13:42 776 查看
class OpenChrome(unittest.TestCase):
   

def setUp(self):

       #打开chrome浏览器,路径中双斜杠

        self.chromedriver = "C:\\Program Files (x86)\\Google\\Chrome\\Application\\chromedriver.exe"
        os.environ["webdriver.chrome.driver"] = self.chromedriver

       #去掉提示

        options = webdriver.ChromeOptions()

        options.add_experimental_option("excludeSwitches", ["ignore-certificate-errors"])
        self.driver= webdriver.Chrome(self.chromedriver,chrome_options=options)

       #最大化

        self.driver.maximize_window()

        

        # 隐性等待

        self.driver.implicitly_wait(30)

        self.base_url = "http://www.baidu.com"

        self.verificationErrors = []

        self.accept_next_alert = True

    

 def test_open_chrome(self):

        driver = self.driver

        driver.get(self.base_url)

        try: self.assertEqual("百度一下,你就知道", driver.title)

        except AssertionError as e: self.verificationErrors.append(str(e))
内容来自用户分享和网络整理,不保证内容的准确性,如有侵权内容,可联系管理员处理 点击这里给我发消息
标签: