xpath - Selenium not able to find elements -
selenium not able find elements. trying find id pageheader_logourl it's throwing unable locate element xpath expression.
am doing wrong
here html code
<div id="page" class="page"> <div id="wrapper" class="wrapper"> <div id="header" class="header"> <table width="100%" height="40" cellspacing="0" cellpadding="0" border="0" id="table2"> <tr> <td> <table height="40" cellspacing="0" cellpadding="0" border="0" id="table3"> <tr> <td><a href="http://www.scania.com" id="pageheader_logourl" tabindex="-1" target="_blank"><span id="headerlogoimage"></span></a></td> <td valign="middle"><label id="pageheader_lblprojectname" class="projectname">scania trucks – sss 4 testr1</label></td>
here snapshot of selenium code:
driver.findelement(by.xpath("//input[@name='usernameinputtext']")).sendkeys(username); driver.findelement(by.xpath("//input[@name='brand']")).sendkeys(password); driver.findelement(by.xpath("//input[@name='cmdlogin']")).click(); assert.asserttrue(isuserloggedin(),"login failed"); } public boolean isuserloggedin() { boolean flag = false; if (!driver.findelements(by.id("cancel")).isempty() || driver.findelement(by.xpath("//a[@id=['pageheader_logourl']")).isdisplayed()); { flag = true; } return flag;
there seems error of 1 [ in xpath
. may want try "//*[@id='pageheader_logourl']"
you can more strategies here
Comments
Post a Comment