Why is it difficult to Automate?
To interact with DOM elements, Selenium Commands should specify the target elements using their xpaths.
click //input[@value='Google Search' and @type='button']To determine the xpath we can use tools like xpath add-on for Firefox or record and get the xpath from Selenium IDE. But the biggest challenge here with ExtJS is this xpath changes every time page reloads as element IDs are randomly generated by default.
So the xpath generated using above mentioned ways will give some thing like
//div[@id='ext-gen77']/div[12]/table/tbody/tr/td[4]/divThis xpath will get changed every time you reload the page. So if you try to run the test it gives
[error] Element //div[@id='ext-gen77']/div[12]/table/tbody/tr/td[4]/div not found
How did I solve this?
To solve this Problem we need Firefox Browser with Firebug, Selenium IDE Add-On installed.
Record the Test Case using Selenium IDE
Open your Application UI which is developed in ExtJS. Right click on some element like Edit Button and say "Inspect Element"
Replace xpath which got recorded with xpath=//button[text()='edit'] because every time the screen gets reloaded, this xpath changes as Element ID is getting generated randomly. This xpath is determined by Tag name which is "button" and value of tag is "edit".
Few times you may need to use class like xpath=//span[@class='x-menu-item']. This xpath is determined by Tag name which is "span" and value of class is "x-menu-itmt".
I'm not having success using your suggestion. Can you please explain it in more detail. I'm having problems with Trees specifically and cannot get it to work. When I record any operation on a Tree it it fails during playback for the same reasons you've detailed for buttons. Any help would be GREATLY appreciated, thanks!
ReplyDeleteWell, after some stops and starts I did get it working using span as you instructed. Still having some issues with other elements (combo boxes, check boxes) but will keep fighting with it and hope for the best :-).
ReplyDeleteSorry Dude I haven't looked at your comments for a long time.. All the Best :)
ReplyDeleteWorks like a treat! Thank you.
ReplyDeleteWelcome :)
ReplyDeleteWorks totally awesome!!!! Thanks a llot man! Can u provide some more tutorials like this on how to determine xpath for tabs, header bar, grid entries, etc. as I am aving difficulty with those!
ReplyDeleteThanks :) Sure definitely I will.
ReplyDeleteFor ExtJS testing tool that does not suffer due to dynamically generated ids you may want to have a look at RIATest: http://www.cogitek.com/riatest/features/technologies/extjs.html
ReplyDeleteExtJS UI widgets are first class citizen in RIATest. The tests in RIATest operate in terms of ExtJS UI widgets and RIATest knows that the dynamic ids must be ignored. Instead it uses widget type, its label, etc to identify it.
So for example the 'Edit' button from your sample is identified simply as ExtButton("Edit").
Thanks for your informative post; selenium is portable automation testing tool to validate the performance and behavior of a software application or environment. Best Selenium training institute in Chennai
ReplyDeleteI very much enjoyed this article. Nice article thanks for given this information. I hope it useful to many People
ReplyDeleteLoadRunner Training in Chennai
LoadRunner Training
Performance Testing Training in Chennai
Performance Testing Training
ReplyDeleteHey, would you mind if I share your blog with my twitter group? There’s a lot of folks that I think would enjoy your content. Please let me know. Thank you.
Automation anywhere Training in Chennai | Best Automation anywhere Training Institute in Chennai
uipath training in chennai | Best uipath training Institute in chennai
Blueprism Training in Chennai | Best Blueprism Training Institute in Chennai
Rprogramming Training in Chennai | Best Rprogramming Training Institute in Chennai
Machine Learning training in chennai | Best Machine Learning training Institute in chennai
Good post. I learn something totally new and challenging on blogs I stumble upon on a daily basis. It will always be interesting to read articles from other authors
ReplyDeleteAndroid Training Institute in Chennai | Android Training Institute in anna nagar | Android Training Institute in omr | Android Training Institute in porur | Android Training Institute in tambaram | Android Training Institute in velachery