xpath - Selenium - unable to find element- during second time -
i trying find element -
select servtypeda = new select (driver.findelement(by.xpath("//select[@id='servicestype']"))); servtypeda.selectbyvisibletext(servtypedata); this works fine first time, when load page. trying workflow when page loads after couple of steps, same line throws error -
org.openqa.selenium.nosuchelementexception: unable locate element
but able see element in screen , visible still not accessible code. tried add wait time, still throws error. why same element not accessible second time?
nosuchelement thrown when webdriver not able find element in dom. main cause of probaly searching element early. suggest use explicit wait , check element regular interval.
by byxpath = by.xpath("//select[@id='servicestype']"); webelement element = new webdriverwait(driver,10).until(expectedconditions.visibilityofelementlocated(byxpath)); select servtypeda = new select(element); servtypeda.selectbyvisibletext(servtypedata);
Comments
Post a Comment