Search code examples
phpphpunitselenium-webdriversendkeysace-editor

sendKeys doesn't work in Selenium webdriver


First I am trying sendKeys at Selenium IDE Like that

Command waitForElementPresent Target css=.ace_text-input Value=

Command sendKeys Target css=.ace_text-input Value=<?php echo 'Hello World'; ?>

Command click Target id=save_changes Value=
and it is ok at the Selenium IDE.

But I have problem at Selenium Webdriver I am writing test for PHP like the following.

$this->assertTrue($this->isElementPresent("css=.ace_text-input"));

$this->sendKeys("css=.ace_text-input", <?php echo 'Hello World'; ?>

$this->click("id=save_changes");

Webdriver never show me an errors but in real <?php echo 'Hello World'; ?> value never type in my test.So, I want to type <?php echo 'Hello World'; ?> at my test. And I am testing Code Editor name is ace_editor and it is just acceptable for sendKeys command. So, Everybody answer welcome to my question.


Solution

  • You may use the value() method, like this:

    $passwordElement=$this->byCssSelector('input[name="LoginForm\[password\]"]');
    $passwordElement->value('123456');