Warning: file_get_contents(/data/phpspider/zhask/data//catemap/8/selenium/4.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Selenium 验证始终在更改的元素编号_Selenium_Selenium Ide - Fatal编程技术网

Selenium 验证始终在更改的元素编号

Selenium 验证始终在更改的元素编号,selenium,selenium-ide,Selenium,Selenium Ide,我如何编写Selenium IDE命令来验证当我通过电子邮件邀请更多人时,该数字是否增加 例如,总人数:30人 示例1:如果我邀请了一个人,我如何验证总人数是否为31人? 例2:如果我邀请了5个人,我如何验证总人数是否为35人 代码如下: <div style="color:#777; font-size:1.3em; float:right; margin-top:5px;"> Total number of people: <span style="

我如何编写Selenium IDE命令来验证当我通过电子邮件邀请更多人时,该数字是否增加

例如,总人数:30人 示例1:如果我邀请了一个人,我如何验证总人数是否为31人? 例2:如果我邀请了5个人,我如何验证总人数是否为35人

代码如下:

    <div style="color:#777; font-size:1.3em; float:right; margin-top:5px;">
    Total number of people:
    <span style="color:red;">30</span>

总人数:
30

我相信您必须:

  • 存储要执行的邀请数量的值
  • 存储预期人数的值(即当前加邀请)
  • 去做邀请
  • 存储新的总人数的值
  • 将新数字与预期数字进行比较
  • 下面是数字的捕获和比较。您只需添加用于实际邀请的部分

    <tr>
        <td>store</td>
        <td>5</td>
        <td>people_invited</td>
    </tr>
    <tr>
        <td>storeText</td>
        <td>//div[contains(text(),'Total number of people')]</td>
        <td>original_count_text</td>
    </tr>
    <tr>
        <td>storeEval</td>
        <td>parseInt(storedVars['original_count_text'].match(/\d+/))+parseInt(storedVars['people_invited'])</td>
        <td>expected_count</td>
    </tr>
    <tr>
        <td>echo</td>
        <td>Go invite 5 people</td>
        <td></td>
    </tr>   
    <tr>
        <td>storeText</td>
        <td>//div[contains(text(),'Total number of people')]</td>
        <td>new_count_text</td>
    </tr>
    <tr>
        <td>storeEval</td>
        <td>parseInt(storedVars['new_count_text'].match(/\d+/))</td>
        <td>new_count</td>
    </tr>
    <tr>
        <td>verifyExpression</td>
        <td>${expected_count}</td>
        <td>${new_count}</td>
    </tr>
    
    
    商店
    5.
    受邀人士
    storeText
    //div[包含(text(),“总人数”)]
    原始\u计数\u文本
    仓库
    parseInt(storedVars['original\u count\u text'].match(/\d+/)+parseInt(storedVars['people\u invested']))
    期望值
    回声
    去邀请5个人
    storeText
    //div[包含(text(),“总人数”)]
    新的\u计数\u文本
    仓库
    parseInt(storedVars['new\u count\u text'].匹配(/\d+/)
    新计数
    验证表达式
    ${预期的\u计数}
    ${new_count}