python+selenium+chrome网页自动化

python+selenium+chrome网页自动化测试:

1、在pycharm中安装selenium:file-setting-project interpreter 中搜索selenium然后进行安装;

2、下载安装谷歌浏览器驱动;
  引用某位同学的安装路径:https://www.cnblogs.com/qiezizi/p/8632058.html  很简单;
下载完之后,我们将下载的文件放在 Python 的根目录下就可以了。

3、新建项目和.Py文件:
举例:
from selenium import webdriver #导入驱动
wd=webdriver.Chrome()                                              
wd.get('https://www.baidu.com/')                               
wd.find_element_by_xpath('//*[@id="kw"]').send_keys("博客园")    
wd.find_element_by_xpath('//*[@id="su"]').click()                 

猜你喜欢

转载自www.cnblogs.com/jeanny2019/p/12106488.html
今日推荐