I have spent like 5 hours trying to find the selector for that success message down there , for my Selenium c# test with not luck. My test always fail saying cannot locate the element!!
Any idea what selector I can use???
I have tried xpath, Css, Classname with all the plugins...
public IWebElement alertSuccessfulAlert => WebDriver.FindElement(By.XPath("//div[contains(text(),'Registration is successful')]")); public IWebElement alertSuccessfulAlert => WebDriver.FindElement(By.CssSelector("body:nth-child(2) my-app:nth-child(1) div.container:nth-child(2) > main.row:nth-child(1)"));
The bubble message Registration is successful is generated through a JavaScript so you have to induce WebDriverWait for the desired ElementToBeClickable()
and you can use either of the following Locator Strategies :
XPath
:
public IWebElement alertSuccessfulAlert = new WebDriverWait(driver, TimeSpan.FromSeconds(20)).Until(ExpectedConditions.ElementToBeClickable(By.XPath("//div[contains(., 'Registration is successful')]")));
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.