简体   繁体   English

将关键字发送到Selenium中的GXT integerSpinnerField

[英]Sendkeys to a GXT integerSpinnerField in Selenium

I have been trying to "sendkeys" to a IntegerSpinnerField but it is not working. 我一直在尝试将“ sendkeys”发送到IntegerSpinnerField,但是它不起作用。 The IntegerSpinnerField has a id but I can't use the "sendkeys" on it. IntegerSpinnerField有一个ID,但是我不能在其上使用“ sendkeys”。 I opened up the html the ID is there but the IntegerSpinnerField is 3 widgets in 1. So is there anyway i can give an id to the 3 widgets that make up the IntegerSpinnerField. 我打开了html,那里有ID,但是IntegerSpinnerField是1中的3个小部件。所以无论如何,我可以给组成IntegerSpinnerField的3个小部件一个ID。

html-code HTML代码

<div __gwtcellbasedwidgetimpldispatchingfocus="true" __gwtcellbasedwidgetimpldispatchingblur="true" id="maximumfrequencySpinnerField" class="GJCAMDBBOPB" title="Enter an maximum frequency  value within the allowable range. The allowed range is  776 to 787 MHz" style="width: 100px;"><div style="width: 100px;" class="GJCAMDBBAW"><table width="100%" cellpadding="0" cellspacing="0"><tbody><tr><td><input style="width: 75px;" type="text" value="" class="GJCAMDBBCV GJCAMDBBJV" id="x-auto-229-input" tabindex="0" disabled=""></td><td><div class="GJCAMDBBKV"></div><div class="GJCAMDBBNV"></div></td></tr></tbody></table></div></div>

Id of the textfield which is autogenerated 自动生成的文本字段的ID

Don't go with id's for ExtJs Applications those were dynamically generated at runtime and prone to change everytime.So you have to write a relative xpath for every element.And ExtJS elements follow some pattern So you have to write xpaths for that and you can reuse them. 不要为ExtJs使用id的应用程序,它们是在运行时动态生成的,并且每次都容易更改。因此,您必须为每个元素编写一个相对的xpath。ExtJS元素遵循某种模式,因此您必须为此编写xpath,并且可以重用它们。

Refer any-suggestions-for-testing-extjs-code-in-a-browser-preferably-with-selenium 请参考任何建议在浏览器中测试extjs代码,最好与硒一起使用

For your case and for most input element you can find it using label.The immediate input of the label might be the element you are looking for 对于您的情况和大多数输入元素,您都可以使用label找到它。标签的立即输入可能是您要查找的元素

I have tested the spinner field named Revenue %: in this demo site using the following xpath 我已经使用以下xpath在此演示站点中测试了名为“ Revenue %:的微调框。

 //label[text()='Revenue %:']//following::input

The script for the above site.Hope it helps 以上网站的脚本。希望对您有所帮助

 WebDriver driver = new FirefoxDriver();
    driver.get("https://www.sencha.com/examples/#ExamplePlace:dashboard");
    WebElement element=driver.findElement(By.xpath("//label[text()='Revenue %:']//following::input"));
    element.clear();
    element.sendKeys("67.67");

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM