What is Send_keys in Selenium?
I was going through the Selenium examples at their website.
I was trying to make the button work on the website for sending an email.
The example given for this is: 1) Click the button "Send". 2) Send a "New Message" by pressing keys "Enter". 3) Open the webmail application. 4) Check the sent message in the inbox. 5) Close the webmail application. This example was for an older version of Selenium, but when I tried to do this for the latest version of Selenium, it just says: InvalidElementStateException: Element must be clickable in order to perform actions on it. So how can I send keys to a non-clickable element? Use the SendKeys function to send keys to the element. You need to provide the Xpath for the element. You can get the Xpath of the element using firebug and get the xpath in firebug by right clicking the element and then selecting inspect element.
For example. String xpath = driver.findElement(By.getAttribute("xpath");
Driver.findElement(By.xpath(xpath)).
What if sendKeys is not working in Selenium?
I tried to use executeScript() but it didn't work as expected. Thanks in advance for your help! I had a similar problem, I had javascript errors in selenium test environment that prevented the correct operation of the "sendKeys". For example: javascriptError="Error executing JavaScript";. It doesn't matter if you use executeScript or webdriver.executeScript( You will have some errors and the sendKeys methods will fail to operate correctly. As far as my knowledge, this only happens in the Firefox Driver for Selenium 3 (version 2.21), in Firefox 15 (which is supported by Selenium RC), there aren't errors but the method doesn't work correctly. The only solution is to modify all the selenium-firefox-rc files and replace the .html files of the Selenium WebDriver. But these are the necessary changes for each project.
As I said, in Selenium 3, the problem occurs. In case you have it, don't worry, everything is ok, but if you're using Selenium RC/1.0, then make sure to check if the version of selenium-firefox-rc is compatible with the Firefox version you are running, otherwise it won't work.
Related Answers
How can we use the Selenium tool with HeadSpin?
Selenium is a tool that is used to automate functional testing. There are two types...
What are 5 Uses of Selenium?
Selenium is a web-automation tool that helps you to test web applications....
How can we use the Selenium tool with HeadSpin?
Selenium is a cross-browser testing automation framework w...