企业网站无线端怎么做,郑州高端网站建设,网站建设制作设计营销 中山,软件中心一、谷歌浏览器配置#xff1a;
在所安装的谷歌下面#xff0c;执行下面命令#xff0c;打开谷歌浏览器#xff0c;用来selenium的操作#xff1a;
注意事项#xff1a;端口需要不被占用#xff0c;--user-data-dirD:\workspace\chrome-data这个路径需要有…一、谷歌浏览器配置
在所安装的谷歌下面执行下面命令打开谷歌浏览器用来selenium的操作
注意事项端口需要不被占用--user-data-dirD:\workspace\chrome-data这个路径需要有权限访问不能放在一个需要管理员访问的路径下否则浏览器打不开
chrome.exe --remote-debugging-port9222 --user-data-dirD:\workspace\chrome-data 二、selenium配置
下面是新版selenium的配置
import logging
from selenium import webdriver
from page_object.searchpage import SearchPagelogging.basicConfig(levellogging.DEBUG)options webdriver.ChromeOptions()
options.add_experimental_option(debuggerAddress, localhost:9222)driver webdriver.Chrome(optionsoptions)# 访问网址
driver.get(http://www.baidu.com)
print(driver.title)
search SearchPage(driver)
search.input_search(selenium)
老版selenium配置为
from selenium import webdriver
from selenium.webdriver.chrome.options import Options
chrome_options Options()
chrome_options.add_experimental_option(debuggerAddress, 127.0.0.1:9222)
driver webdriver.Chrome(chrome_optionschrome_options)运行效果 执行代码时有时会比较慢需要有点耐心。