-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
  • 397
  • 2
  • 7
  • 24
  • Can you show the whole file please? – Guru Stron Apr 30 '20 at 23:36
  • Also please look at this question: https://stackoverflow.com/a/49867605/2501279 – Guru Stron Apr 30 '20 at 23:38
  • Please include code as text, not as images. – DiplomacyNotWar Apr 30 '20 at 23:46
  • 1
    And read [tagging help](https://stackoverflow.com/help/tagging) which states _"The only time you should use tags in your title is when they are organic to the conversational tone of the title."_. Ergo, you should not prefix every question with "Selenium C#" because you have already tagged your question as such. – DiplomacyNotWar Apr 30 '20 at 23:47
  • 1
    The property name is clashing with the class name. Rename the property or refer the the class using a fully qualified class name. – Greg Burghardt May 01 '20 at 00:15

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
  • 16,381
  • 7
  • 46
  • 83
  • 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
  • 397
  • 2
  • 7
  • 24
  • 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