Skip to content

Explicit Wait not working in Appium 1.8.0 with c# client #225

@Gocoollnath

Description

@Gocoollnath

Description

Explicit wait not working and the sever doesn't wait for the time specified for the object to be present

Environment

Appium version 1.8.0
Desktop OS/version used to run Appium: Windows 10 Pro
Node.js version (unless using Appium.app|exe): 8.10.0
Mobile platform/version under test: Android API 25 ,v7.1.1
Real device or emulator/simulator: Real Device Samsung Tab
Appium CLI or Appium.app|exe: both
IDE: VisualStudio 2017 Enterprise and C# as coding language

Code To Reproduce Issue [ Good To Have ]

new WebDriverWait(driver, TimeSpan.FromMilliseconds(50000)).Until(ExpectedConditions.ElementToBeClickable(By.ClassName("android.widget.Spinner")));

and also tried this code

new WebDriverWait(driver,FromMilliseconds(50000)).Until(X=>X.FindElement(By.Id("elementid");

WebDriverWait wait = new WebDriverWait(driver, TimeSpan.FromSeconds(50));
Func<IWebDriver, IWebElement> waitForElement = new Func<IWebDriver, IWebElement>((IWebDriver Web) =>
{

             IWebElement element = Web.FindElement(By.XPath("//android.widget.Button[@text='OK']"));
             if (element.GetAttribute("style").Contains("red"))
             {
                 return element;
             }
             return null;
         });

IWebElement ok =wait.Until(waitForElement);

Ecxeption stacktraces

Test Name: TestMethod1
Test FullName: UnitTestProject1.UnitTest1.TestMethod1
Test Source: C:\Users\gokulnath.kumar\source\repos\UnitTestProject1\UnitTestProject1\UnitTest1.cs : line 25
Test Outcome: Failed
Test Duration: 0:01:49.3963396

Result StackTrace:

at OpenQA.Selenium.Remote.RemoteWebDriver.UnpackAndThrowOnError(Response errorResponse)
at OpenQA.Selenium.Remote.RemoteWebDriver.Execute(String driverCommandToExecute, Dictionary2 parameters) at OpenQA.Selenium.Appium.AppiumDriver1.Execute(String driverCommandToExecute, Dictionary2 parameters) at OpenQA.Selenium.Remote.RemoteWebDriver.FindElement(String mechanism, String value) at OpenQA.Selenium.Remote.RemoteWebDriver.FindElementByXPath(String xpath) at OpenQA.Selenium.By.<>c__DisplayClass19_0.<XPath>b__0(ISearchContext context) at OpenQA.Selenium.By.FindElement(ISearchContext context) at OpenQA.Selenium.Remote.RemoteWebDriver.FindElement(By by) at OpenQA.Selenium.Appium.AppiumDriver1.FindElement(By by)
at AMCS_Mobile.Page_Objects.Vehicle_Selector_Objects.OK_btn() in C:\Users\gokulnath.kumar\source\repos\UnitTestProject1\UnitTestProject1\Page_Objects\Vehicle_Selector_Objects.cs:line 36
at AMCS_Mobile.Vehicle_Selector.Vehicle_selector.Vehicle_Selector(String Vehiclename) in C:\Users\gokulnath.kumar\source\repos\UnitTestProject1\UnitTestProject1\App_Modules\Vehicle_selector.cs:line 30
at UnitTestProject1.UnitTest1.TestMethod1() in C:\Users\gokulnath.kumar\source\repos\UnitTestProject1\UnitTestProject1\UnitTest1.cs:line 29
Result Message:
Test method UnitTestProject1.UnitTest1.TestMethod1 threw exception:
System.InvalidOperationException: An element could not be located on the page using the given search parameters.

Link to Appium logs

https://gist.github.com/Gocoollnath/547096033a7ff6a9bc4c89b9f30f7d1b

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions