Advertisement

pytest-selenium运行demos

阅读量:

准备工作概述

1、获取Python安装包

2、通过pip工具安装pytest-selenium模块

代码:

复制代码
 from selenium.webdriver.common.by import By

    
  
    
  
    
 def test_baidu_so_get_value(selenium):
    
     selenium.get('http://www.baidu.com/')
    
  
    
     kw = selenium.find_element(By.ID, 'kw')
    
     kw.send_keys('NBA')
    
  
    
     assert kw.get_attribute('value') == 'NBA'
    
    
    
    

通过命令行界面进行操作:

复制代码
 pytest TestCase/test_case.py --driver Chrome --html=report/result.html

    
  
    
 ============================================== test session starts ======================

全部评论 (0)

还没有任何评论哟~