Selenium with Kendo UI

为君一笑 提交于 2019-12-24 18:55:29

问题


We are using Kendo UI for our buttons and textbox. It is causing issues for selenium. If user test manually then steps are>> they drag their mouse over to the text box, the text box is highlighted and the user clicks on the textbox. Then the cursor starts to show up and the user can type in.

As for selenium 'driver.findElement' is able to find the textbox but not able to get a cursor. I tried textbox.click and mouse event too,


回答1:


Try to set value of element using the executeScript method:

JavascriptExecutor js = (JavascriptExecutor)driver;
js.executeScript("document.getElementById('elementID').setAttribute('value', 'yourValue')");

EDIT:

But as @JeffC already mentioned, it is not a "clear" solution. The better one you can see below.

As you can see here the text box is working as following:

  1. you have to click on the first input via this xPath: //ul[@id = 'fieldlist']/li[1]/label/span/span/input[1]

it is this input field:

  1. Before clicking on first input the second input

had display:none. And now it has display:inline-block, so we can perform sendKeys() action on this(second) element via this xPath //ul[@id = 'fieldlist']/li[1]/label/span/span/input[2].

The same thing you can do in your case.

PS in the code it would be like this:

WebElement firstInput = driver.findElement(By.xpath("//ul[@id = 'fieldlist']/li[1]/label/span/span/input[1]")); 
firstInput.click();

new WebDriverWait(driver,10).until(ExpectedConditions.visibilityOfElementLocated(By.xpath("//ul[@id = 'fieldlist']/li[1]/label/span/span/input[2]")); // waits until second input becomes visible

WebElement secondInput = driver.findElement(By.xpath("//ul[@id = 'fieldlist']/li[1]/label/span/span/input[2]")); 
secondInput.sendKeys("55");


来源:https://stackoverflow.com/questions/50764183/selenium-with-kendo-ui

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!