Driver.get(http://www/quikr.com/");
(Driver.findElement(By.xpath("//*[@class ='select_city_main']")).getAttribute("style"));(To get style Value) Returning Blank
(Driver.findElement(By.xpath("//*[@id='header']")).getAttribute("h3"));(To get Tag Value) Returning as "null"
Iam using FF-12 and Webdriver 2.21.0
Please let me know what modification I need to do for this code..
Regards,
Kumar
It looks like you are getting confused.
H3 is an element tag, not an attribute. Style is an attribute but unless it has been explicitly set in the HTML markup it will be blank.
It looks like you want to get css values, not element attributes. Try using:
driver.findElement(By.id("foo")).getCssValue("background-color");
You will of course need to know which css value you are looking for.
--
You received this message because you are subscribed to the Google Groups "Selenium Users" group.
To post to this group, send email to seleniu...@googlegroups.com.
To unsubscribe from this group, send email to selenium-user...@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msg/selenium-users/-/XjixZ9v5nGUJ.
For more options, visit https://groups.google.com/groups/opt_out.
If that' is the html you were trying to run this command on:
(Driver.findElement(By.xpath("//div[@class ='select_city_main']")).getAttribute("style"));
Then you should not expect to get the response "color:white" as you are pointing to the wrong element.
You'd need to point to the specific <a> tag not an unrelated div tag.
This should return "color:white":
(Driver.findElement(By.xpath("//div[@class ='blank1']"/a")).getAttribute("style"));
This should return "Select a classifieds category to find what you are looking for":
(Driver.findElement(By.xpath("//div[@id='header']"/h3")).getText());
This html looks odd ... embedding a <div> inside an <a> looks a somewhat perverse use of html, for example ...
To post to this group, send email to selenium-users@googlegroups.com.
To unsubscribe from this group, send email to selenium-users+unsubscribe@googlegroups.com.
That is because the element doesn’t exists (as the exception told you.
I think you need to take a step back and learn how to use XPath and how to understand HTML.
If you don’t understand HTML you are going to have a lot of problems testing websites. Once you have learnt HTML then go and find out about XPaths as you are obviously getting confused at the moment.
Based on the html you have supplied so far this will return you something:
driver.findElement(By.xpath("//a[div[@class ='select_city_main']]")).getAttribute("style");
However I don’t know if it will return what you want (I’m not even sure you know what you want).
To post to this group, send email to seleniu...@googlegroups.com.
To unsubscribe from this group, send email to selenium-user...@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msg/selenium-users/-/Atg_ZcNPRKMJ.
For more options, visit https://groups.google.com/groups/opt_out.
--
You received this message because you are subscribed to the Google Groups "Selenium Users" group.
To post to this group, send email to seleniu...@googlegroups.com.
To unsubscribe from this group, send email to selenium-user...@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msg/selenium-users/-/P_a_jhhAgc4J.