CodeceptJS学习笔记-入门02
1.打开页面
打开页面,使用I.amOnPage(),如果URL不是以http://或者https://开始的,就则将其视为相对URL,并将其附加到配置文件 codecept.conf.js 中设置的URL后面
// When "https://url" is url in config |
2.点击页面元素
单击定位器提供的链接或按钮。如果给出了模糊定位符,则会在页面上搜索与定位符字符串匹配的按钮,链接或图像。对于按钮,将搜索“值”属性,“名称”属性和内部文本。对于链接,将搜索链接文本。对于图像,将搜索“ alt”属性和任何父链接的内部文本。
第二个参数是上下文(CSS或XPath定位器),以缩小搜索范围。
//使用Xpath定位//使用css定位//搜索链接文本//参考CSS/Xpath,缩小搜索文本的范围//doubleClick与click用法差不多 |
3.输入框输入
//使用css定位//使用Xpath定位// or by strict locator |
4.下拉框选项
//发现这个只支持select,咱们triones上面都是ul/li,用的话会报错Error | Error: Element is not <select> |
4.React定位
{ react: 'MyComponent' }{ react: 'Button', props: { title: 'Click Me' }}{ react: 'Button', state: { some: 'state' }}{ react: 'Input', state: 'valid'}//react:标签名,props是该元素的属性I.click({react: 'button', props: { type: 'button',class: 'ant-btn ant-btn-primary',style :'width: 100%; height: 36px;' }}) |
5.断言
5.1 see
5.2 seeAttributesOnElements
|
|
5.3 seeCookie
|
|
6.等待
//等待2s//等待可点击的元素出现,默认等待1s//等待文本出现 |
7.按键
支持的特殊键名
Some of the supported key names are:'AltLeft' or 'Alt''AltRight''ArrowDown''ArrowLeft''ArrowRight''ArrowUp''Backspace''Clear''ControlLeft' or 'Control''ControlRight''Command''CommandOrControl''Delete''End''Enter''Escape''F1' to 'F12''Home''Insert''MetaLeft' or 'Meta''MetaRight''Numpad0' to 'Numpad9''NumpadAdd''NumpadDecimal''NumpadDivide''NumpadMultiply''NumpadSubtract''PageDown''PageUp''Pause''Return''ShiftLeft' or 'Shift''ShiftRight''Space''Tab' |

浙公网安备 33010602011771号