I have a problem with trigger keypress event in WebDriver with using php. There is element with class > test On this element bind keypress by jquery . I try to click,but its no result
$this->_city = $this->driver->findElement(WebDriverBy::className('test'));
$this->_city->click()
Plz, help me, who know how to emulate keypress on webdriwer with using php.
You mention a keypress event, so some type of key on the keyboard being pressed is what you are looking for? Using the click() event is emulating a mouse click on the element in question. You will probably want to use the sendKeys() function once the element has focus.
$this->_city = $this->driver->findElement(WebDriverBy::className('test'));
$this->_city->click()
$this->_city->sendKeys('A');
$this->_city = $this->driver->findElement(WebDriverBy::className('test'));
$this->_city->click()
$this->driver->getKeyboard()->sendKeys('TEXT HERE'); // this will insert text in the box
$this->driver->getKeyboard()->pressKey(WebDriverKeys::ENTER); // This will do a enter or whatever key you like to press ( not letter/numbers move ARROW_UP or whatever you like to presskey)
Here are some other keys for the driver:
The only one worked for me is WebDriverKeys
:
$driver->getKeyboard()->pressKey(WebDriverKeys::ENTER);
Hope this helps.