SVG tags and Css Selectors
Sample:
<div id="fsdf" class="dsdfds"/>
<svg xmlns="http://www.w3.org/2000/svg" version="1.1" width="264" height="250"/>
<defs/>
<rect rx="dsfd" ry="45" fill="sdf"/>
<g class="highcharts-tracker" zIndex="1"/>
<g />
<rect fill="rgb(123,222,222) NEED TO GET HERE />
<svg xmlns="http://www.w3.org/2000/svg" version="1.1" width="264" height="250"/>
<defs/>
<rect rx="dsfd" ry="45" fill="sdf"/>
<g class="highcharts-tracker" zIndex="1"/>
<g />
<rect fill="rgb(123,222,222) NEED TO GET HERE />
1. //[local-name()='svg']
2. //*[local-name()='svg']
3. //*[local-name()='svg']//*[local-name()='g']
4. //*[local-name()='svg']//*[local-name()='g'][1]
5. //*[local-name()='g'][@class='highcharts-tracker']/*[local-name()='g']
6. //*[local-name()='g'][@class='highcharts-tracker']/*[local-name()='g']/*[local-name()='rect'][1]
7. //*[@class='highcharts-tracker']/*[local-name()='g']/*[local-name()='rect'][1]
8. //*[@class='highcharts-tracker']//*[local-name()='rect'][1]
driver.findElement(By.xpath("//*[@class='highcharts-tracker']//*[local-name()='rect'][1]")).click()
OTHER EXAMPLES
driver.findElement(By.cssSelector("//*[local-name()='svg' and namespace-uri()='http://www.w3.org/2000/svg']//*[local-name()='tspan' and text()='Me']"));
driver.findElement(By.cssSelector("//*[local-name()='svg' and namespace-uri()='http://www.w3.org/2000/svg']//*[local-name()='tspan' and text()='You']"));
driver.findElement(By.cssSelector("//*[local-name()='svg' and namespace-uri()='http://www.w3.org/2000/svg']//*[local-name()='tspan' and text()='None']"));
Ref:
http://automatethebox.blogspot.in/2012/10/how-to-locate-element-in-svg-tag-in.html
https://code.google.com/p/selenium/issues/detail?id=6441
this is really too useful and have more ideas from yours. keep sharing many techniques. eagerly waiting for your new blog and useful information. keep doing more.
ReplyDeleteSchool Logo Design UK
this is really too useful and have more ideas from yours. keep sharing many techniques. eagerly waiting for your new blog and useful information. keep doing more.
ReplyDeleteNew Zealand education Consultants in Chennai
Selenium WebDriver fits in the same role as RC did, and has incorporated the original 1.x bindings. It refers to both the language bindings and the implementations of the individual browser controlling code. This is commonly referred to as just "WebDriver" or sometimes as Selenium 2.
ReplyDeleteSelenium Training Institute in Chennai
Selenium Training in Chennai
Trending in Selenium Training in Velachery.
How to use CSS Selector as Locator is one of the important point to note down, What is CSS Selector ?
ReplyDeleteCSS Selector is combination of an element selector and a selector value which identifies the web element within a web page. The composite of element selector and selector value is known as Selector Pattern.
Know more:
Selenium Training in Chennai
Selenium Training in Velachery
Great step by step solution, thanks for the help!
ReplyDeleteselenium Online Training Bangalore
Thanks for the Great Article.Thanks For Posting.
ReplyDeleteSelenium Online Training Hyderabad