PHPUnit硒不支持sendKeys吗? [英] PHPUnit selenium doesn't support sendKeys?
问题描述
我正在Selenium IDE上使用sendKeys
命令编写测试,这很好.但是,当我更改为PHPUnit Selenium时,遇到的错误是Method sendKeys not defined
,所以我想知道PHPUnit-Selenium
不支持还是我需要添加一个方法?如果答案是我需要添加senKeys
方法,那么我就知道如何添加senKeys
方法.
I was writing test with sendKeys
command at Selenium IDE that was fine. But when I was change to PHPUnit Selenium I got an error that was Method sendKeys not defined
, so I want to know is PHPUnit-Selenium
doesn't support or I need to add a method? If the answer is I need to add senKeys
method if so let's me know how to add senKeys
method.
推荐答案
我暂时也无法弄清楚这个……窍门是它不叫做sendKeys,并且您不使用{ENTER}带有Selenium的PHPUnit.这些不是您要查找的功能!
I couldn't figure this one out either for a while... the trick is that it's not called sendKeys and you don't use {ENTER} in PHPUnit with Selenium. These are not the functions you are looking for!
相反,单击要键入的元素,然后使用键功能,如下所示:
Instead, click on the element you wish to type into and then use the keys function like so:
$this->byXpath('//*[@id="theOneToTypeIn"]')->click();
$this->keys('some keys to type'.Keys::ENTER);
确保在页面顶部还包括Keys类:
Make sure that at the top of your page you include the Keys class as well:
use PHPUnit_Extensions_Selenium2TestCase_Keys as Keys;
The supported keys can be found here: https://code.google.com/p/selenium/wiki/JsonWireProtocol#/session/:sessionId/element/:id/value
我读到支持SendKey的方式与JSON线框中的方式相同,因此我可以想象这些常量与该链接中的名称是相同的...但是然后,我还想象到所有函数名称都可以一样,我们就在这里.
I read that the SendKeys are supported the same was as in the JSON wire frame so I would imagine that the constants are the same names as they are in that link... but then I also imagined that all the function names would be the same and here we are.
这篇关于PHPUnit硒不支持sendKeys吗?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!