Monday, May 13, 2024
 Popular · Latest · Hot · Upcoming
158
rated 0 times [  160] [ 2]  / answers: 1 / hits: 25374  / 11 Years ago, tue, january 14, 2014, 12:00:00

My javascript line:



$('#name').show();


My webdriver code line:



wait.until(ExpectedConditions.visibilityOfElementLocated(By.id(name))).sendKeys(Some Name);


When I run the test it throws the following exception:



WebDriverException: unknown error: cannot focus element


So, I have been searching for a solution. There are some issues reported in chromium google code site. There are a lot of suggestions about using JavaScriptExecutor. But it doesn't seem a better solution for me, because it could make a browser dependent code.


More From » java

 Answers
119

After some hours I finally found a solution by using Actions without JavascriptExecuter:



Actions actions = new Actions(driver);
actions.moveToElement(website);
actions.click();
actions.sendKeys(Some Name);
actions.build().perform();


Well, it worked for me. However, is this way the better solution ?


[#73171] Monday, January 13, 2014, 11 Years  [reply] [flag answer]
Only authorized users can answer the question. Please sign in first, or register a free account.
dustin

Total Points: 599
Total Questions: 105
Total Answers: 106

Location: Belarus
Member since Tue, Mar 14, 2023
1 Year ago
dustin questions
;