Selenium设置浏览器的启动语言

python3.7

Chrome: 

            # 修改lang=zh-CN即可更改语言, 可在 https://blog.csdn.net/Sam_ONE/article/details/102571595 下寻找对应的

    chrome_options = webdriver.ChromeOptions()
            chrome_options.add_argument('lang=zh-CN')
            driver = webdriver.Chrome(options=chrome_options)
 
Firefox:
     # FireFox_Configure_path 为火狐浏览器不同语言下的配置文件,firefox_path为火狐浏览器 geckodriver.exe的所在目录
     ffprofile = webdriver.FirefoxProfile("%s"%FireFox_Configure_path )
             driver = webdriver.Firefox(executable_path=firefox_path, firefox_profile=ffprofile)

猜你喜欢

转载自www.cnblogs.com/TestDeveloper/p/12743552.html