Open cwk2 opened 2 years ago
If I let the screen load - I can find the element using
var element = driver.FindElementByName("Profile");
So its not an issue of mis-identification of the element, it's a problem with the wait..
@cwk2 Try next code:
var waitForMe = new WebDriverWait(driver, TimeSpan.FromSeconds(20));
waitForMe.Until(ExpectedConditions.VisibilityOfAllElementsLocatedBy(By.Name("Profile")));
@Shakevg - that worked, thank you! Do you have any explanation as to why my initial code didn't work? Would be helpful for my understanding!
@cwk2 I suppose answer here (Issue that you get Displayed from a null element that throws WebDriverException that not handle by WebDriverWait): https://stackoverflow.com/a/21004586/8951897
Source codes of WebDriverWait and VisibilityOfAllElementsLocatedBy: https://github.com/SeleniumHQ/selenium/blob/702b3aae7385adf331d75cdeacd79720cf6b9c84/java/src/org/openqa/selenium/support/ui/WebDriverWait.java#L126 https://github.com/DotNetSeleniumTools/DotNetSeleniumExtras/blob/dc402a5d7b9d7e78a9ce293bdb64b0b9a47685d5/src/WaitHelpers/ExpectedConditions.cs#L141
When I attempt to use WebDriverWait to wait for an element to be displayed before interacting with it, I get an error immediately, and the wait doesn't occur.
OpenQA.Selenium.WebDriverException: 'An element could not be located on the page using the given search parameters.'
Am I doing something wrong or is this a known issue? Thanks!