I want to select the values of attributes of an element. e.g If I have an input element
<input type="text" name=myInput value="100">
I can locate it using input[name='myInput']
, but how do I get the value of it using a css selector?
BTW, I am trying to do this in Selenium using css selectors
You might want to explain what you're trying to do with the value. For instance, I have the following CSS to display the text of the links in the '#content' element in my print style sheet:
#content a:link:after, #content a:visited:after {
content: " (" attr(href) ") ";
font-size: 90%;
}
#content a[href^="/"]:after {
content: " (http://example.com" attr(href) ") ";
}
If in Perl using WWW::Selenium then it's simply:
my $val = $selenium->get_value("css=input[name='myInput']");
If using another language then the Selenium library should support a get_value function/method.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With