Reputation:
I am having handling a drop down button in EXTJS application which i am trying to automation with selenium web driver.
clicking on the image i will get a list of elements in the form of 's to click select from
Please help me how i can device a xpath to click this image, which i should not use "id" (as its extjs it might vary every now and then). if there are any selector i can use for extjs please suggest. Thanks for your help.
<DIV id=ext-gen2337 class=x-form-field-wrap style="WIDTH: 0px"><INPUT id=ext-gen2023 class=" x-form-text x-form-field" style="WIDTH: 297px" readOnly size=24 value="Clients with pending exceptions" name=ext-gen2023 autocomplete="off"><IMG id=ext-gen2338 class="x-form-trigger x-form-arrow-trigger" src="https:REDACTED/com.ssc.epw.gui.EPWHome/clear.cache.gif">
Upvotes: 0
Views: 1635
Reputation: 43
I would do something like this:
driver.findElement(By.xpath("//div[contains(@class, 'x-form-field-wrap')]//img"));
or
driver.findElement(By.xpath("//img[contains(@src, 'https://REDACTED/com.ssc.epw.gui.EPWHome/clear.cache.gif')]"));
Upvotes: 0
Reputation: 3629
So if you want to start testing ExtJS app and you don't want to use the best solution for this such as Sencha Test or Bryntum Siesta.
The best way to approach this is to write you own layer between the ExtJS components and the html dom of the site.
You can see more info in my answer here https://stackoverflow.com/a/41718879/1768843
But what you need to do is to use the Ext.Component.Query, with Selenium you can execute the javascript code on the site. So you execute the ext query and you pass there the Ext selector - for example button[text=something]
or panel[name=mainPanel]
simply any ExtJS component selector. This will return you the ExtJS object and with it you can simply call .getDom()
or .getId()
which will return you the actual dom or id used in the HTML. Next you can simply use the webdriver functions for clicking (or something) on the HTML elements in the site.
^^ You need to do this because the ExtJS framework can generate the HTML every-time little bit differently. For example you add new container or you upgrade your ExtJS version and the HTML is changed and your test can stop working. But if you call the Ext components as log as the Ext source code is still the same your tests will be always working.
But doing this is quite a hassle and lot of work. It's much better to use prepared solutions such as Sencha Test where everything is already prepare for testing ExtJS apps.
Upvotes: 0
Reputation: 52665
Try below XPath
to match required img
element:
//input[@value="Clients with pending exceptions"]/following-sibling::img
Upvotes: 1