java - How do I locate an element whose partialTagValues are dynamic -
i error saying 'an invalid or illegal selector specified'. note:- in last findelement statement, have given cssselector ("//td[id*='verificationmsg']/p[2]) because id closest unique locator find capture data. , part of doesn't change. eg:- current id value id="m_7959323670053369637verificationmsg" number keeps changing in recurring emails "verificationmsg" part of doesn't.
this in reference previous question , suggestions got
package amazon; import java.awt.awtexception; import java.awt.robot; import java.awt.event.keyevent; import java.util.iterator; import java.util.set; import java.util.concurrent.timeunit; import org.openqa.selenium.by; import org.openqa.selenium.keys; import org.openqa.selenium.webdriver; import org.openqa.selenium.webelement; import org.openqa.selenium.chrome.chromedriver; import org.openqa.selenium.interactions.actions; public class verifyamazonsigninpage { public static void main(string[] args) throws awtexception { // todo auto-generated method stub system.setproperty("webdriver.chrome.driver", "c://selenium jars/chromedriver.exe"); webdriver driver = new chromedriver(); driver.manage().timeouts().implicitlywait(20, timeunit.seconds); driver.get("http://www.gmail.com"); driver.findelement(by.id("identifierid")).sendkeys("gaurav.thantry@gmail.com"); robot rob = new robot(); rob.keypress(keyevent.vk_enter); rob.keyrelease(keyevent.vk_enter); driver.findelement(by.name("password")).sendkeys("******"); rob.keypress(keyevent.vk_enter); rob.keyrelease(keyevent.vk_enter); driver.findelement(by.xpath("//span[text()='amazon password assistance']")).click(); string v = driver.findelement(by.cssselector("td[id*='verificationmsg']/p[2]")).gettext(); system.out.println(v); } }
scratch guys. got it. //*[contains(@id,'verificationmsg')]/p[2]. works.
wiki
Comments
Post a Comment