【问题标题】:assertRegExp phpunit & selenium can't read integer valueassertRegExp phpunit & selenium 无法读取整数值
【发布时间】:2013-12-13 14:13:23
【问题描述】:

我有一个关于使用 phpunit 和 selenium 进行自动化测试的问题。我要测试的选项卡显示文本和整数,例如。 'All Open (56)',其中整数可以根据它拥有的记录数而改变。我有一个测试用例,用于测试此菜单选项卡上的文本:

public function testHasAllOpenTab()
{
    $this->url('index.php'); // Set the URL to test
    // check for the existence of the strin 'All Open'
    $this->assertRegExp( '/All Open/i', $this->source() );        
}

但我想要测试文本是否也包含一个从 0 到 100 的数字。 我努力了: $this->assertRegExp('/全部打开(/(s*0,\s*255)/', $element->source());

但我仍然得到错误。有人可以帮忙吗? 谢谢 康纳

【问题讨论】:

    标签: php phpunit selenium-webdriver


    【解决方案1】:

    试试这样的

    $this->assertRegExp( '/All Open \((\d|[1-9]\d|1\d\d|2[0-4]\d|25[0-5])\)/i', $this->source() );        
    
    • \d - 都是一位数
    • [1-9]\d - 所有两位数都不是从 0 开始
    • 1\d\d - 全部 1**
    • 2[0-4]\d - 所有 20*,21*,22*,23*,24*
    • 25[0-5] - 和 250,251,252,253,254,255

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 1970-01-01
      • 2018-04-17
      • 1970-01-01
      • 2017-11-10
      • 1970-01-01
      • 1970-01-01
      • 2014-02-13
      • 2014-09-22
      相关资源
      最近更新 更多