English 中文(简体)
WebdriverIO Tutorial

Selected Reading

Handling Checkboxes & Dropdowns
  • 时间:2024-03-18 19:08:42

Handpng Checkboxes and Dropdowns


Previous Page Next Page  

我们可以在自动交换器中处理检查箱,同时利用网络用户信息进行测试。 检查箱在《html法典》中被确认为投入和检查箱的类型。

以下屏幕将登在你的电脑上:

Handle Checkboxes

一些使用检查箱的方法如下:

cpck()

它用于检查一个检查箱。

Syntax

The syntax is as follows -


let p = $( #loc )
p.cpck()

isSelected()

用于检查是否选定了一类检查箱。 它收回了“蓝宝”价值(如果检查,即行不通)。

The syntax is as follows -


let p = $( #loc )
p.isSelected()

首先,遵循题为“快车道”的一章第1至5号步骤。

。 题为“从诺德JS开始的结晶”的章节详细介绍了如何安装这些装置。

。 关于如何安装这一装置的细节见题为“建立国家预防机制”的章节。

。 关于如何安装这些装置的细节见题为VS代码安装的一章。

。 关于如何进行安装的细节见题为“配置文件生成”的章节。

Step 5——建立光谱档案。 关于如何安装这些装置的细节见题为“Mocha装置”的章节。

在制作的Mocha光谱档案中添加以下代码。


// test suite name
describe( Tutorialspoint apppcation , function(){
   //test case
   it( Checkbox , function(){    
      // launch url
      browser.url( https://the-internet.herokuapp.com/checkboxes )
      //identify checkbox with CSS then cpck
      const p = $("input[type= checkbox ]") 
      p.cpck()
      //verify if checked with assertion
      expect(p).toBeSelected()
      //uncheck checkbox
      p.cpck()
      //verify if not checked with assertion
      expect(p).not.toBeSelected()
   });
});

档案——由以下指挥部存档:


npx wdio run wdio.conf.js

在题为“Wdio.conf.js案”的章节和题为“编造档案”的章节中详细讨论了如何建立汇编档案的细节。

以下屏幕将登在你的电脑上:

Happy Path Flow

指挥工作成功执行后,所有提名者都按预期执行,我们经过测试。

Handpng Dropdowns

我们可以在使用网络用户组织进行测试自动化的同时,处理国际交易日志的下降。 定点下降在《html法典》中,标号为选择,其选择权为选择。

以下屏幕将登在你的电脑上:

Handpng Dropdowns

Methods for Static Dropdowns

一些静态下降的方法如下:

这种方法用来选择一种与作为这种方法参数而采用的一种选择的明显文本相匹配的办法。

The syntax is as follows -


let p = $( #loc )
p.selectByVisibleText( By Subject )

这种方法用来选择一种与作为该方法参数的任何属性的价值相符的选择。

The syntax is as follows -


let p = $( #loc )
p.selectByAttribute( value ,  subject )

这里,这一选择具有价值。

这种方法用来选择一种与作为这种方法参数的备选办法的指数/定位相匹配的办法。 指数从0开始。

The syntax is as follows -


let p = $( #loc )
p.selectByIndex(1)

getValue()

这种方法用于获得在下降时选择的一种选择的属性价值。

The syntax is as follows -


let p = $( #loc )
p.getValue()

首先,遵循题为“快车道”的一章第1至5号步骤。

。 题为“从诺德JS开始的结晶”的章节详细介绍了如何安装这些装置。

。 关于如何安装这一装置的细节见题为“建立国家预防机制”的章节。

。 关于如何安装这些装置的细节见题为VS代码安装的一章。

。 关于如何进行安装的细节见题为“配置文件生成”的章节。

Step 5——建立光谱档案。 关于如何安装这些装置的细节见题为“Mocha装置”的章节。

在制作的Mocha光谱档案中添加以下代码。


// test suite name
describe( Tutorialspoint apppcation , function(){
    //test case
    it( Drodowns , function(){    
        // launch url
        browser.url( https://www.tutorialspoint.com/tutor_connect/index.php )  
        //identify dropdown 
        const p = $("select[name= selType ]") 
        //select by index
        p.selectByIndex(1)
        //get option selected
        console.log(p.getValue() +   - option selected by index )
        //select by visible text
        p.selectByVisibleText( By Subject )
        //get option selected
        console.log(p.getValue() +   - option selected by visible text )
         //select by value attribute
         p.selectByAttribute( value ,  name )
         //get option selected
         console.log(p.getValue() +   - option selected by attribute value )
    });
});

档案——由以下指挥部存档:


npx wdio run wdio.conf.js

在题为“Wdio.conf.js案”的章节和题为“编造档案”的章节中详细讨论了如何建立汇编档案的细节。

以下屏幕将登在你的电脑上:

DropDown

指挥工作成功执行后,首先,选择指数的选择价值——名称在议会印刷。

然后,选择可读写文本的选项,其价值在专册中印刷。

最后,选择属性价值的办法的价值——名称在册。

Advertisements