首页 > 编程语言 >python+playwright 学习-25 expect 常用的断言方法

python+playwright 学习-25 expect 常用的断言方法

时间:2023-03-09 10:14:14浏览次数:44  
标签:25 playwright visible python text Element locator expect

前言

playwright 提供了一个 expect方法 用于断言

expect 使用

断言 描述
expect(locator).to_be_checked() Checkbox is checked
expect(locator).to_be_disabled() Element is disabled
expect(locator).to_be_editable() Element is enabled
expect(locator).to_be_empty() Container is empty
expect(locator).to_be_enabled() Element is enabled
expect(locator).to_be_focused() Element is focused
expect(locator).to_be_hidden() Element is not visible
expect(locator).to_be_visible() Element is visible
expect(locator).to_contain_text() Element contains text
expect(locator).to_have_attribute() Element has a DOM attribute
expect(locator).to_have_class() Element has a class property
expect(locator).to_have_count() List has exact number of children
expect(locator).to_have_css() Element has CSS property
expect(locator).to_have_id() Element has an ID
expect(locator).to_have_js_property() Element has a JavaScript property
expect(locator).to_have_text() Element matches text
expect(locator).to_have_value() Input has a value
expect(locator).to_have_values() Select has options selected
expect(page).to_have_title() Page has a title
expect(page).to_have_url() Page has a URL
expect(api_response).to_be_ok() Response has an OK status

to_be_checked()使用示例

from playwright.sync_api import expect

locator = page.get_by_label("Subscribe to newsletter")
expect(locator).to_be_checked()

to_be_visible()使用示例

from playwright.sync_api import expect

locator = page.locator('.my-element')
expect(locator).to_be_visible()

标签:25,playwright,visible,python,text,Element,locator,expect
From: https://www.cnblogs.com/yoyoketang/p/17197319.html

相关文章

  • python 批量提取.txt文件的前缀名称
    importtkinterastk#导入tkinter库设置别名tkimportosimporttimeimportglobroot=tk.Tk()#生成主窗口root.title('文件提取器')#设置窗体名字root......
  • mac python 版本管理
    安装pyenvbrewinstallpyenvecho-e'ifwhichpyenv>/dev/null;theneval"$(pyenvinit-)";fi'>>~/.bash_profilesource~/.bash_profile查看版本pyenv......
  • 3.8python的学习笔记
    a=[1,2,3,4,5,6,7,8,9,0]#importrandom#c=random.randint(0,9)随机生成一个0-9得整数在数组中查看下标得位置#b=a[c]#print(b)#print(c)10a=[3.14,5,"qa","张三......
  • 实验1 Python开发环境使用和编程初体验
    #实验任务1#1.1.py#用法1print('hey,u')#用法2print('hey','u')x,y,z=1,2,3print(x,y,z)#用法3print('x=%d,y=%d,z=%d'%(x,y,z))print('x={},y={},z={}'.for......
  • python基础(4)
    1.什么是可变不可变类型?答:可变不可变类型是指修改变量值后,变量的id是否还一样,一样就是可变类型,不一样就是不可变类型。int、float、str、bool都是不可变类型;list、dict是可......
  • python快速入门1
    记录python若干功能特点,帮助快速了解python语法  #!/usr/bin/envpython#验证若干python功能importpandasaspdimportnumpyasnpimporttimeimportdate......
  • Python|Flask中的@
    现代Web框架使用路由技术来帮助用户记住应用程序URL,可以直接访问所需的页面,而无需从主页导航。Flask中的route()装饰器用于将URL绑定到函数。例如:@app.route('/hello')de......
  • python入门学习-2.特性、函数、面向对象编程、文件读写
    高级特性切片取一个list或tuple的部分元素>>>L=['Michael','Sarah','Tracy','Bob','Jack']笨方法:>>>[L[0],L[1],L[2]]['Michael','Sarah','Tracy']切......
  • percona-server-8.0.25-15源码编译安装
    ###############################     初始化:mysqld--initialize#mysqld--initialize--user=work--basedir=/home/work/mysql_3306--datadir=/home/wo......
  • Python学习日志
    今天开始了第一次学习python,配置了python的所需环境完成了PythonCharm的编译器运行可视化界面。完成了“helloworld”的输出,了解了基本计算语句和规则  还有字符型......