怎样使用Python调用我们平时使用的chrome浏览器

在Mac系统上执行,Python脚本要如何写?chromedrive调用平时使用的chrome,而不是一个非常干净的chrome?

import unittest,os,time
from selenium import webdriver
from selenium.common.exceptions import NoSuchElementException

dictInput = {}

class Test(unittest.TestCase):
    def setUp(self):
        self.chromedriver = "C:\Users\xxx\AppData\Local\Google\Chrome\Application\chromedriver.exe" # 将chromedriver.exe拷贝到你想要调用的chrome安装路径下即可
        os.environ["webdriver.chrome.driver"] = self.chromedriver
        self.browser = webdriver.Chrome(self.chromedriver)
    def test(self):
        self.browser.get('xxxx')#此处xxxx为网页的url
if __name__ == '__main__':
    import sys;sys.argv = ['', 
                             'Test.test'
                               ]
    unittest.main()

追问

你这个是windows系统上执行的代码,而且调用出来的页面也是一个非常干净的chrome;现象:本机的chrome 是安装了插件的,但调出来的chrome就是没有插件的。

追答

chrome是可以设置启动参数的,只有看看selenium的源码了,是不是可以改

温馨提示:内容为网友见解,仅供参考
第1个回答  2015-04-01
os.system直接调用不就行了
相似回答