java - how to get text from following code -
html code
<label for="ctl00_contentplaceholder1_radpanelbar1_i0_chkcolumns_4">job title</label>
i have text in page above html code can see in firebug text. need text "job title" .
the code have written
string jobtitle= driver.findelement(by.id("ctl00_contentplaceholder1_radpanelbar1_i0_chkcolumns_4")).getattribute("label"); reporter.log(jobtitle+" displayed",true);
i tried gettext method not working ... when used above code displaying
null displayed
in console
first, need check if label visible or not selenium doesn't supports reading text invisible elements. secondly, per code, trying check if label visible or not. there property "displayed" that. driver.findelement(by.xpath("xpath label")).displayed
call return true or false depending upon label visible or not.
no, if want read text, in case .text attribute returs text if label visible. if not visible, should try .getattribute("innerhtml"). should work you.
Comments
Post a Comment