With Selenium 1.0
Let us consider Google Search Box for example and its "max length"is to be retrieved.
Using xPath -
Using css locator -
With Selenium 2.0 (WebDriver)
Using xPath -
Using css locator -
Let us consider Google Search Box for example and its "max length"is to be retrieved.
Using xPath -
String var = selenium.getAttribute("//input[@name='q']/@maxlength"); System.out.println(var);
Using css locator -
String var = selenium.getAttribute("css=input[name='q']@maxlength"); System.out.println(var);
With Selenium 2.0 (WebDriver)
Using xPath -
String var = webDriver.findElement(By.xpath("//input[@name='q']")).getAttribute("maxlength") System.out.println(var);
Using css locator -
String var = webDriver.findElement(By.cssSelector("input[name='q']")).getAttribute("maxlength") System.out.println(var);
your posts are helpful. Really it will be more helpful if you provide with online sites examples(google.com, ebay.in).So, the starter can easily implement in his own way!!!
ReplyDeleteI have modified the examples to consider Google Search box. Hope this helps.
ReplyDelete