Selenium Python自动化测试学习知识积累-页面常用操作
来源:互联网 发布:mac 终端删除文件夹 编辑:程序博客网 时间:2024/04/27 14:37
#encoding=utf-8import unittestfrom selenium import webdriverimport timeclass BrowserTest(unittest.TestCase): def setUp(self): #启动浏览器 self.driver =webdriver.Firefox(executable_path="F:\\Python\\Webdriver\\geckodriver.exe") def test_vistUrl(self): #访问网页 self.driver.get("http://www.sogou.com") #刷新当前页面 self.driver.refresh() #获取浏览器在屏幕中的位置 position =self.driver.get_window_position() print("当前浏览器所在的横坐标:",position['x']) print("当前浏览器所在的纵坐标:",position['y']) #设置当前浏览器在屏幕上的位置 self.driver.set_window_position(200,400) #获取当前浏览器的大小,返回字典类型 sizeDict =self.driver.get_window_size() print("当前浏览器的窗口宽:",sizeDict['width']) print("当前浏览器的窗口高:",sizeDict['height']) #设置浏览器窗口大小 self.driver.set_window_size(400,200) #获取页面title title =self.driver.title print("当前页面的title属性为:",title) #获取页面html源码 pagesource =self.driver.page_source print(pagesource) #获取页面url地址 url=self.driver.current_url print(url) self.assertEqual(url,"https://www.sogou.com/","当前网页地址和预期不符!") # 窗口最大化 #self.driver.maximize_window() def tearDown(self): #退出浏览器 self.driver.quit()
阅读全文
0 0
- Selenium Python自动化测试学习知识积累-页面常用操作
- Selenium Java自动化测试学习知识积累-定位页面元素
- Selenium Python自动化测试学习知识积累-unittest
- Selenium Java自动化测试学习知识积累-环境搭建
- Selenium Java自动化测试学习知识积累-TestNG
- 【Python】学习selenium自动化测试:操作浏览器
- Selenium Java自动化测试学习知识积累-我的第一个自动化项目
- Python+Selenium前端页面测试自动化
- python+selenium自动化测试学习笔记一
- python + selenium 自动化测试
- selenium + python 自动化测试
- Python自动化测试-Selenium
- selenium + python 自动化测试
- Python+Selenium使用Page Object实现页面自动化测试
- selenium+python自动化测试(三)--页面元素定位
- selenium+python自动化测试(二)--使用webdriver操作浏览器
- 6、Selenium + Python 实现 UI 自动化测试-鼠标操作
- 7、Selenium + Python 实现 UI 自动化测试-键盘操作
- JVM字节码之整型入栈指令(iconst、bipush、sipush、ldc)
- 第十三周项目1--线性表的顺序查找
- SVN基础
- ubuntu14.04设置静态IP
- GROUP BY 和 ORDER BY 子句联合使用组合查询
- Selenium Python自动化测试学习知识积累-页面常用操作
- 云星数据---Scala实战系列(精品版)】:Scala入门教程004-Scala数组详解003
- HDU 2870(动态规划-最大子矩阵)
- angularjs表格的增删改查完成功能
- 越狱苹果iOS Cydia添加源图解
- 插入排序
- 判断是否为空是否有敏感词,是否有匹配项
- 第12周项目1-验证算法
- Spring MVC 中 HandlerInterceptorAdapter的使用