i trying press "grid" class button on web page having trouble. here html:
<li id="prodlist" class="prodtab"> <span> products</span> <div class="grid" onclick="gotoview('productgrid');"></div> <div class="list" onclick="gotoview('productlist')"></div> </li> here tried gives org.openqa.selenium.nosuchelementexception:
driver.findelement(by.xpath("div[contains(@class, 'grid')]")).click();
the solution kind of problems either switch iframe, if element inside it:
webelement frame = driver.findelement(by.cssselector("iframe.ajaxstorenumberappendsrc")); driver.switchto().frame(frame); // then, search element driver.findelement(by.xpath("//div[contains(@class, 'grid')]")).click(); or, make explicit wait wait element become present:
webdriverwait wait = new webdriverwait(webdriver, 5); wait.until(expectedconditions.presenceofelementlocated(by.xpath("//div[contains(@class, 'grid')]")));
Comments
Post a Comment