Hi all,
I’m using Selenium WebDriver with C#, and I have the following code that used to work without issues:
try
{
IWebDriver driver = (IWebDriver)VR[“_selenium_driver_script_reference_chromeReference”];
WebDriverWait waitSearch = new WebDriverWait(driver, TimeSpan.FromSeconds(120));
// Store the web element
IWebElement iframe = waitSearch.Until(ExpectedConditions.ElementIsVisible(By.Id(“iFrameWFix”)));
// Switch to the frame
driver.SwitchTo().Frame(iframe);
VR[“elementPresent”] = true;
}
catch
{
VR[“elementPresent”] = false;
}
But now I’m getting this error:
Error in expression: The name ‘ExpectedConditions’ does not exist in the current context
Any help or updated guidance would be much appreciated — especially if you know a modern workaround for this.
Thanks!
- Marijano asked 2 weeks ago
- You must login to post comments
Hi,
i found it as well
we need to switch to using a lambda-based wait instead of ExpectedConditions as it’s deprecated
As i’ve found it explained: “This is pure WebDriver and won’t ever get deprecated”
try
{
IWebDriver driver = (IWebDriver)VR[“_selenium_driver_script_reference_chromeReference”];WebDriverWait waitSearch = new WebDriverWait(driver, TimeSpan.FromSeconds(120));
//Store the web element
//OLD
//IWebElement iframe = waitSearch.Until(ExpectedConditions.ElementIsVisible(By.Id(“iFrameWFix”)));
//INSTEAD
var iframe = waitSearch.Until(drv =>
{
var e = drv.FindElement(By.Id(“iFrameWFix”));
return e.Displayed ? e : null;
});//Switch to the frame
driver.SwitchTo().Frame(iframe);VR[“elementPresent”] = true;
}
catch
{
VR[“elementPresent”] = false;
}
Hope this helps!
- Lac answered 2 weeks ago
- You must login to post comments
Please login first to submit.