-1

I'm trying to do an explicit wait to go around using Thread.Sleep(), but I'm always getting this issue with the ElementExists. I'm not sure if I'm missing a directive or I need to declare something.

enter image description here

TestProjectDemo

WebDriverWait wait = new WebDriverWait(driver, TimeSpan.FromSeconds(10));
driver.Navigate().GoToUrl("https://bi7-azure.test.com/");
wait.Until(ExpectedConditions.ElementExists(By.Id("appList")));
driver.Navigate().GoToUrl("https://bi8.test.com/azure/");
Thread.Sleep(10000);
driver.Navigate().GoToUrl("https://insightsmp.test.com/");
Thread.Sleep(10000);

BaseClass(this is where I'm declaring the objects)

using NUnit.Framework;
using OpenQA.Selenium;
using OpenQA.Selenium.IE;
using OpenQA.Selenium.Support.UI;
using System;

namespace TestProject.BaseClass
{
    public class BaseClassTrigger
    {  
        public IWebDriver driver;
        public object wait;
        public object ExpectedConditions;
Kent Abrio
  • 445
  • 2
  • 9
  • 27

2 Answers2

1

You have a property on BaseClass named ExpectedConditions. The property name conflicts with the ExpectedConditions class name in the OpenQA.Selenium.Support.UI namespace. Either:

  • Rename the ExpectedConditions property in BaseClass or
  • Use the fully qualified class name: OpenQA.Selenium.Support.UI.ExpectedConditions

Most likely the ExpectedConditions property in BaseClass was a mistake introduced by choosing the wrong option in the "Quick actions and refactorings" menu in Visual Studio when trying to resolve the OpenQA.Selenium.Support.UI namespace. I would just remove the ExpectedConditions property in BaseClass.

Greg Burghardt
  • 17,900
  • 9
  • 49
  • 92
  • It's not accepting the fully qualified class name though, and the red underline is on ExpectedConditions saying "The name ExpectedConditions" does not exist in the current context". – Kent Abrio May 01 '20 at 00:26
0

I fixed it by installing Selenium.Support; however, it says that it is already deprecated, the recommended way around this is to make your own function from scratch and call that function whenever you need the wait condition.

Kent Abrio
  • 445
  • 2
  • 9
  • 27
  • The ExpectedConditions and PageFactory classes have been moved to another GitHub repository, which currently has no owner. Things like WebDriverWait are still supported. – Greg Burghardt May 01 '20 at 10:59