【问题标题】:PHPUnit Selenium getting value out of HTMLPHPUnit Selenium 从 HTML 中获取价值
【发布时间】:2014-09-22 04:45:45
【问题描述】:

对此仍然很陌生,我正在努力从 HTML 中获取价值。 我正在使用 Sebastian Bergmann 的 PHPUnit selenium webdriver

HTML:

<div class="col-lg-7 col-md-7">
<input type="text" id="function_function_name" name="function[function_name]" disabled="disabled" class="form-control input-sm" value="JOBSTUDENT">
</div>

我尝试了什么:

$functie = $this->webDriver->findElement(WebDriverBy::id('function_function_name'))->getText();

结果:回显是空白。(因为没有文字,不知道怎么定位值)

然后我发现了getValueText,但是当我尝试使用它时:

$functie = $this->webDriver->findElement(WebDriverBy::id('function_function_name'))->getValueText(); 

我得到了这个结果: PHP 致命错误:调用未定义的方法 RemoteWebElement::getValueText()

输出将回显“ JOBSTUDENT ” 我在做什么错/忘记了?

【问题讨论】:

    标签: php selenium phpunit


    【解决方案1】:

    我认为是getAttribute():

    $functie = $this->webDriver
                   ->findElement(WebDriverBy::id('function_function_name'))
                   ->getAttribute('value');
    

    我不确定 By::id() 是否真的针对 id 或名称。你可以试试这个:

    -&gt;findElement(WebDriverBy::id('function[function_name]')

    【讨论】:

    • 你先生,是个天使。我会在 9 分钟内接受它作为答案,就像魅力一样谢谢!
    猜你喜欢
    • 1970-01-01
    • 2016-11-28
    • 2014-08-24
    • 1970-01-01
    • 2021-04-05
    • 2016-03-30
    • 1970-01-01
    • 1970-01-01
    • 2019-06-25
    相关资源
    最近更新 更多