Tricks to be faster

Hi guys !
I’m trying to be a test system really fast, but it take (sometimes) a long time to find an element on the screen (like 1 or 2 seconds). Do you have some tricks to save time on each step?

Try to disable reporting from capabilities, your runs may get faster.

2 Likes

I’m not sure of the code line to do it, is it dc.setCapability(SeeTestCapabilityType.REPORT_FORMAT, false); ?

The main problem is to read a value on my app, the value change every 0.5sec, and the command driver.findElement(By.xpath("//*[@x='32']")).getText() , take about 2sec to get the value, so I miss a lot of value…

Appium Studio automatically generates these capabilities:

dc.setCapability("reportDirectory", reportDirectory);
dc.setCapability("reportFormat", reportFormat);
 dc.setCapability("testName", testName);

You can just remove them from your code (in your IDE).

As for xpath, some testers argue that this method is relatively slower. If you can, try to look for the element using By.id or By.name or any other valid identifier.

I tryed a lot of different things with findelement, and it takes about 6sec to find an element, I can’t be faster… Is it the same for you?

in my test (under C#) some steps takes about ~2.3 seconds to make:

  • Find item and click to load new page
  • Find new item to ensure everything is ok

For me is this time is ok but no idea if it’s possible to get values as fast as every 0.5 seconds.

In my test sytem, the same step takes about 12-14seconds… I do it in JAVA do you thing it makes a difference? do you have an exemple of your code in C to try ? (maybe it is because of my computer, or my Iphone…)

sure. I put here some snippets of code:

This one establish the connection to an iOS device. The reporting section is commented to make it faster. This method do not launch any APP, just connect.

private void StartUPIOS()
{
    try
    {
        configuracion.appium_DesiredCapabilitiesIOS = new DesiredCapabilities();

        //configuracion.appium_DesiredCapabilitiesIOS.SetCapability
            //    ("reportDirectory", configuracion.appium_reportDirectory);
            //configuracion.appium_DesiredCapabilitiesIOS.SetCapability
            //    ("reportFormat", configuracion.appium_reportFormat);
            //configuracion.appium_DesiredCapabilitiesIOS.SetCapability
            //    ("testName", configuracion.appium_testName);

            configuracion.appium_DesiredCapabilitiesIOS.SetCapability
                (OpenQA.Selenium.Appium.Enums.MobileCapabilityType.Udid, configuracion.device_IOSUDID);
            configuracion.appium_DesiredCapabilitiesIOS.SetCapability
                (OpenQA.Selenium.Appium.Enums.IOSMobileCapabilityType.BundleId, configuracion.ios_BundleID);
            configuracion.appium_DesiredCapabilitiesIOS.SetCapability
                (OpenQA.Selenium.Appium.Enums.MobileCapabilityType.NoReset, false);
            configuracion.appium_DesiredCapabilitiesIOS.SetCapability
                (OpenQA.Selenium.Appium.Enums.MobileCapabilityType.NewCommandTimeout, 30); 

            //configuracion.appium_Driver = new IOSDriver(new Uri("http://127.0.0.1:4723/wd/hub"),            configuracion.appium_DesiredCapabilitiesIOS);
            //configuracion.appium_Driver.ExecuteScript("client:client.setDevice(\"" + configuracion.script_DeviceName + "\")");

            EscribirEnConsola("Conectado OK!", ConsolaTipoMensaje.OK);
       }
       catch (Exception ex)
       {
           EscribirEnConsola("Error Conectando con dispositivo - " + ex.StackTrace, ConsolaTipoMensaje.Error);                
       }
}

This one is a portion of code that makes click over an item and look for a new one.


configuracion.appium_Driver.FindElement(By.XPath(pasoActual.link)).Click();
while (miCrono.ElapsedMilliseconds < configuracion.script_TimeOut)
    {
       try
       {
           AppiumWebElement item;
           item = configuracion.appium_Driver.FindElementByXPath(pasoActual.validacion);
           if (item != null) break;
       }
       catch (Exception ex)
       {
           //Console.WriteLine("ERROR: " + ex.StackTrace);
           //throw new Exception("5"); 
       }
    }