简体   繁体   中英

Selenium - FireFox/Marionette driver not doing wait.Until

Ever since updating to the Marionette driver. Firefox is no longer doing waits. Basically I want it to log in, wait for the page to load then check to see if its logged in by finding "log out" on the page. Here's my setup

// navigate to url "http://..."
// Find Log In button and .Click()

WebDriverWait wait = new WebDriverWait(driver, System.TimeSpan.FromSeconds(30));
wait.Until(driver1 => ((IJavaScriptExecutor)driver).ExecuteScript("return document.readyState").Equals("complete"));

// Assert if the page contains "Log out"

What's happening is after It Clicks Log In, it's not waiting for the page to load so it will throw an error because it can't find "Log out"

I stress that the code worked for the older Firefox driver (Not Marionette) and also Chrome's driver. Anyone else getting an issue with the new Firefox Driver not doing waits?

Sorry I should have been clearer, Firefox driver isn't doing ANY waits, so waiting on an element existing won't work either

The reason your test is failing is what Jonny stated in the comments. You are waiting for the page to be ready immediately after the log in action, which is already 'ready' as you have just interacted with it. What you want to do is do an implicit wait on the log off element. This can be done with a couple different methods.

wait.Until(ExpectedConditions.ElementExists(By.XPath(xpath)));

wait.Until(ExpectedConditions.ElementExists(By.CssSelector(csspath)));

Either one of these will perform an implicit wait on the page, waiting up to 30 seconds (as defined in your wait element) for the log off element to be found.

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.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM