appium / dotnet-client

Extension to the official Selenium dotnet webdriver
Apache License 2.0
385 stars 187 forks source link

[WithTimeSpan(Second = ...)] attribute ignored #205

Closed agriardyan closed 3 years ago

agriardyan commented 6 years ago

Description

I'm trying to implement page object on certain project. I'm very keen on Java, and there is no issue when using @WithTimeout annotation to wait either until element present or timeout. Just migrating to C#, I found that the equivalent @WithTimeout annotation is [WithTimeSpan] attribute, which I implement then I notice it's do nothing. Since I can't perform wait with that, Appium keep telling me no such element. I've adjust seconds up to 50 seconds, and even minutes (although on manual test, it should only wait for less than 10 seconds).

Environment

Details

I implement it such as below. This class called from unit test. And yes, I have satisfy all capabilities.

using OpenQA.Selenium;
using OpenQA.Selenium.Appium;
using OpenQA.Selenium.Appium.Interfaces;
using OpenQA.Selenium.Appium.PageObjects.Attributes;
using OpenQA.Selenium.Support.PageObjects;
using OpenQA.Selenium.Support.UI;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading;
using System.Threading.Tasks;

namespace AppiumTraining.page
{
    class AltusLoginPage
    {
        private AppiumDriver<AppiumWebElement> driver;

        public AltusLoginPage(AppiumDriver<AppiumWebElement> driver)
        {
            this.driver = driver;
            PageFactory.InitElements(driver, this);
        }

        [WithTimeSpan(Seconds = 30)]
        [FindsBy(How = How.XPath, Using = "//*[@id='Input_UsernameVal2']")]        
        private IWebElement customerCodeField;

        public void doSomething()
        {
            customerCodeField.Clear();
            customerCodeField.SendKeys("Altus");
        }
    }
}

Link to Appium logs

I don't think logs are related to this issue, but here is it. https://gist.github.com/agriardyan/a2159ab6aff422b520fc85df63b78d2f

vikrampvr commented 6 years ago

Hi,

This seems to be big issue when you are implementing pageobjects pattern in Appium with C#. I tried many options with no success. Test fails immediately without waiting for control to load. As mentioned above [WithTimeSpan(Seconds = 30)] attribute is being ignored. Tried
duration = new TimeOutDuration(new TimeSpan(0, 0, 30)); PageFactory.InitElements(driver, map, new AppiumPageObjectMemberDecorator(duration));

and some other options as well but nothing seems to be working.