测试开发-02(web自动化测试)

1. selenium的安装(根据浏览器的类型和版本选择安装)

2. selenium IDE用力录制(插件的使用)

3. selenium测试用例编写

#selenium 测试用例编写--Chorme打开csdn官网,点击博客(blog)栏
from selenium import webdriver
from selenium.webdriver.common.by import By

class TestCase1:
    def setup_method(self, method):
        self.driver = webdriver.Chrome()
        self.driver.implicitly_wait(3)//隐式等待

    def teardown_method(self, method):
        self.driver.quit()

    def test_01(self):
        self.driver.get("https://www.csdn.com")
        self.driver.find_element(By.LINK_TEXT,"Blog").click()

4. 隐式等待与显式等待

#直接等待
import time
time.sleep()

#隐式等待,n秒前加载完毕则不再等待,最多等待n秒
self.driver.implicitly_wait()

#显示等待(方式1:定义函数,查找element出现作为条件)
from selenium.webdriver.support.wait import WebDriverWait
from selenium.webdriver.common.by import By

def wait(x):
    return len(self.driver.find_elements(By.LINK_TEXT,"Blog")) >=1
WebDriverWait(self.driver,10).until(wait)

#显示等待(方式2:采用内嵌函数expected_conditions)
from selenium.webdriver.support.wait import WebDriverWait
from selenium.webdriver.support import expected_conditions
from selenium.webdriver.common.by import By

WebDriverWait(self.driver,10).until(expected_conditions.element_to_be_clickable(By.LINK_TEXT,"Blog"))

5. web控件定位与常见操作

常见操作:点击、输入

基本控件定位方法:xpath、cssSelector

web控件定位与常见操作(测试、爬虫)-CSDN博客

6.web交互基本操作

常见操作:右键点击、页面滑动、表单操作

web交互基本操作-CSDN博客

  • 1
    点赞
  • 2
    收藏
    觉得还不错? 一键收藏
  • 2
    评论
评论 2
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值