How to get value from page using WebDriver >> find elements -
how value hierarchy selenium webdriver , webelement? web page application telerik model.
part of java code:
public void changeelementsaveandverify() throws interruptedexception { driver.findelement(by.xpath(myprintertab.printertabiconleftpane)).click(); thread.sleep(5000); driver.findelement(by.xpath(myprintertab.showhidedriverdetailed)).click(); thread.sleep(5000); webelement select = driver.findelement(by.id("ctl00_contentplaceholder2_radgrid_driver_ctl00_ctl05_editformcontrol_preton_ucsettings_driver_treelist_ctl04_enabled_dropdown")); webelement innerelemt = select.findelement(by.tagname("div")); webelement innerelemt2 = innerelemt.findelement(by.tagname("ul")); list<webelement> alloptions = innerelemt2.findelements(by.tagname("li")); (webelement option : alloptions) { system.out.println("value is: "+ option.gettext()); system.out.println(option.getattribute("value")); driver.findelement(by.xpath(myprintertab.arrowusepreton)).click(); thread.sleep(5000); option.click(); thread.sleep(5000); driver.findelement(by.xpath(myprintertab.savebutton)).click(); }
page source
<div class="rcbslide" style="z-index: 6000; visibility: visible; display: block; overflow: visible; margin-left: 0px; position: absolute; top: 328px; left: 1122.5px; height: 42px; width: 370px;"> <div id="ctl00_contentplaceholder2_radgrid_driver_ctl00_ctl05_editformcontrol_preton_ucsettings_driver_treelist_ctl08_graphicmode_dropdown" class="radcomboboxdropdown radcomboboxdropdown_default " style="display: block; visibility: visible; top: 0px; left: 0px; width: 368px;"> <div class="rcbscroll rcbwidth" style="width: 100%; overflow: auto; height: 40px;"> <ul class="rcblist" style="list-style:none;margin:0;padding:0;zoom:1;"> <li class="rcbitem "> … </li> <li class="rcbhovered "> … </li> </ul> </div> </div> </div>
the webelement getting findelement
has no such attributes text value. try finding correct webelement using different by-mechanism (by.id or by.xpath).
if not working, post html easier help.
Comments
Post a Comment