Hi All,
Iām currently creating my first automation framework and first test case - so far so good, but Iām now running into serious issues trying to get a decent āwaitā implemented.
My research so far is telling me that explicit waits are better practice than implicit wait, and sleeps should be avoided like the plague unless absolutely unavoidable. The test that I am running against the website is intermittently throwing up āelement not foundā or āelement not visibleā exceptions and terminating the test run - if I rerun the test then the previous exception might suddenly pass but then another one will fail.
I can only presume that this behaviour is down to the time the site is taking to load elements, but the thing thatās really confusing me is that even when I wait for an element to be present and then try to interact with it, I may still get an exception sometimes.
For example, Iāll do this check to ensure that this element is available:
new WebDriverWait(Driver.Instance, TimeSpan.FromSeconds(20)).Until(ExpectedConditions.ElementExists((By.XPath(//LABEL[@data-toggle='dropdown))));
Then Iāll click on it:
Driver.Instance.FindElement(By.XPath("//LABEL[@data-toggle='dropdown")).Click();
But this will sometimes not work. The element is a dropdown menu and I know itās on the page and should be clickable, so am completely stumped!
Any advice on a good approach to waiting to a: run tests and quickly as possible and b: not have them fall over due to running too quickly would be greatly appreciated
Thanks,
James