#SFSE: XPath Alternative for Browser Automation in IE

Preview:

Citation preview

XPath alternative for Browser Automation in IE

About Me

Mridul Bansal Graduate Student, Software Engineering (Dec’11) San Jose State University Software QA Intern @Citrix, CA Software Test Development Intern @Hara, CA Software Test Engineer @Covelix, India http://www.linkedin.com/in/mridulbansal

Problem Statement

Automation in IE using Webdriver!!!

Caution!

  n00b

  Lot has already been said…

  Take with a pinch of salt

Caution!

IE9

Why?

 Dynamic id

 XPath

 Handles XPath differently

  Painfully Slow

Fix?

  Increase timeout

 CSS

 Alternate locators

iFix

 Nokogiri (Ruby) http://nokogiri.org/ gem install nokogiri require ‘nokogiri’

How?

Earlier @driver.find_element(:xpath => "//span[contains(., ABC')]").click

Now src = "<div id=""treeForm:tree:childs"">#{@driver.page_source()}</

div>" curr_id = Nokogiri::HTML(src).xpath("//div[@id =

'treeForm:tree:childs']/div[1]/div[2]/table[11]").attribute("id")

@driver.find_element(:id, curr_id).click

Benchmarks

  Test execution time on FF3.6 using

Webdriver = 3:00

  Test execution time on IE9 using Webdriver = 4:50

Alternatives

 HtmlCleaner - http://htmlcleaner.sourceforge.net/

References

  http://nokogiri.org/   http://php.jglobal.com/blog/?

tag=selenium   http://www.qaautomation.net/?p=216   http://blog.altom.ro/2010/10/selenium-

xpath-and-internet-explorer.html

Credits

 Selenium Meetup

 Hara

 Huynh Kang

©  2011  Hara  

/  confiden0al  /  

Page  14  Open House

Appreciate in Public, Criticize in private… Recommend on LinkedIn!

©  2011  Hara  

/  confiden0al  /  

Page  15  My Takeaway!

Thanks for bearing!!

Mridul Bansal Graduate Student, Software Engineering (Dec’11) San Jose State University Software QA Intern @Citrix, CA Software Test Development Intern @Hara, CA Software Test Engineer @Covelix, India http://www.linkedin.com/in/mridulbansal

Recommended