This site is in read only mode. Please continue to browse, but replying, likes, and other actions are disabled for now.
1 / 13
Aug 2015

I am using Appium and selenium web driver for Android application automation testing , Since last 3 weeks I am noticing that when I try to find elements with array , Appium find it continue at least for 2 minutes always and I want to make that time like 30 seconds.

My Code is here :

List uploaderror = driver.findElements(By.xpath(AppConstants.uploaderror));

if(uploaderror.size()<=0)
{

       //Do Something

}

In above code I am trying to find multiple elements and depends on element size I apply further action. Issue is appium takes very long time to find element , I want to control that time. I have tried all types of waits but no success.

Please let me know if anyone already faced this and resolved.

  • created

    Aug '15
  • last reply

    Nov '17
  • 12

    replies

  • 21.1k

    views

  • 8

    users

  • 9

    likes

  • 6

    links

We had a lot of problems getting the timing for searching for elements under control. We decided to use the Selenium wait object to limit the amount of time that we search. To wit,

wait = Selenium::WebDriver::Wait.new(timeout: 30, interval: 1)
begin
wait.until
# findElement....
end
rescue Selenium::WebDriver::Error::TimeOutError
# report failure
end

There are implicit and explicit waits. Explicit waits allow you to define maximum wait time and as the condition (e.g., visibility of element) is met the wait will stop and next statement will be executed.

Here is the sample method in java:

public void waitForScreenToLoad(AppiumDriver lDriver, WebElement element, int seconds){

          WebDriverWait wait = new WebDriverWait(lDriver,seconds);
          wait.until(ExpectedConditions.visibilityOf(element));

}

Okay , I followed this and now calling function like (waitForElementToLoad(driver, count ,60) , but now how can I integrate it with my condition? can you please explain in short that? My code is there in question for reference.

What is 'count' that you are passing in the function as parameter? is it WebElement?

1 year later

Hi . refer this tutorial to work with implicit and explicit wait with Appium
WebDriverWait wait = new WebDriverWait(driver,20);
wait.until(ExpectedConditions.visibilityOfElementLocated(By.id("about_me")));

20 days later

If you are using PageFactory model with Appium, then you can add implicit wait in InitElements() method as below -

PageFactory.initElements(new AppiumFieldDecorator(driver, 10, TimeUnit.SECONDS), this);

I have tried this with Appium 1.6 and it works fine.

2 months later

@anish10110 can you please clarify if driver is of type WebDriver or AppiumDriver as in both case this is not working with latest java client

Thanks,
Vikram

For the benefit of those who come to this post looking for answer like me, please find below info how I got it working

1> Sample code

2> Refer to post for better info

3> Found an issue wrt this

Regards,
Vikram

5 months later
3 months later

It worked with latest jars:

Appium 1.7.1
Java-client 5.0.4
Selenium-java 3.7.1

AppiumDriver androidDriver will work