Appium学习21:屏幕截图

截图方法

方法1

save_screenshot() 该方法直接保存当前屏幕截图到当前脚本所在文件位置。

driver.save_screenshot('login.png')

方法2

get_screenshot_as_file(self, filename)

将截图保留到指定文件路径

driver.get_screenshot_as_file('./images/login.png')

实践案例

测试场景

在考研帮App登录页面输入用户名和密码之后截图,分别保存到当前文件和指定的文件路径。

代码实现

screenshot.py 

from find_element.capability import driver

driver.find_element_by_id('com.tal.kaoyan:id/login_email_edittext').clear()
driver.find_element_by_id('com.tal.kaoyan:id/login_email_edittext').send_keys('55555')

driver.find_element_by_id('com.tal.kaoyan:id/login_password_edittext').send_keys('zxw2018')

driver.save_screenshot('login.png')
driver.get_screenshot_as_file('./images/login.png')

driver.find_element_by_id('com.tal.kaoyan:id/login_login_btn').click()

 

發表評論
所有評論
還沒有人評論,想成為第一個評論的人麼? 請在上方評論欄輸入並且點擊發布.
相關文章