Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Emulate keypress in webdriver using php

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.

like image 324
user3216669 Avatar asked Jan 20 '14 20:01

user3216669


2 Answers

$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:

Check out more Keys from WebDriverKey

CHECK getKeyboard() Methods

like image 131
Decypher Avatar answered Sep 19 '22 00:09

Decypher


The only one worked for me is WebDriverKeys :

$driver->getKeyboard()->pressKey(WebDriverKeys::ENTER);

Hope this helps.

like image 42
Zakaria Acharki Avatar answered Sep 19 '22 00:09

Zakaria Acharki