xpath - Checking Text exist or not? -
say on stackoverflow "all questions" page.
i want search user "user2402616" (which nowadays on 3rd page) on first page. if not nowadays click on next button until found.i tried below code using xpath getting error.
boolean bpres = driver.findelement(by.xpath("//a[contains(text(),'user2402616')]")).isdisplayed(); system.out.println(bpres); while (!bpres) { driver.findelement(by.xpath("//a[contains(text(),'next')]")).click(); }
since xpath has text in both cases i.e clicking on user , next button . can utilize by.linktext method , pass in value want click
boolean bpres = driver.findelement(by.linktext("user2402616")).isdisplayed(); system.out.println(bpres); while (!bpres) { driver.findelement(by.xpath("next").click(); }
xpath selenium-webdriver
No comments:
Post a Comment