Selenium自动化测试
Primarily Selenium is for automating web applications for testing purposes, but is certainly not limited to just that. Boring web-based administration tasks can (and should) also be automated as well.
介绍
Selenium支持多种语言,包括Java、JS和Python等。
准备工作
- 下载安装Selenium:
$ pip install Selenium - 下载chromedriver
打开测试页面
1 | from selenium import webdriver |
其中<driver_path>指的是存放chromedriver的位置,<url>是我们要进行测试的页面地址。做完了这一步,运行就可以看到chrome浏览器自动打开到指定的页面了。
选择及操作元素
其它有用操作
可能遇到的问题
iframe
已打开页面挂载脚本