Can not execute ElementActionRunner

  • 2 Replies
  • 531 Views
Can not execute ElementActionRunner
« on: July 30, 2018, 16:09:37 pm »
Hi All,
I am facing error as below, could you please help to take a look and give me an advice
Quote
21:01:40.737 [main] DEBUG io.testproject.java.sdk.v2.Runner - Starting development session...
21:01:45.016 [main] INFO  io.testproject.java.sdk.v2.Runner - Development session initialized
21:01:45.022 [main] INFO  io.testproject.java.sdk.v2.Runner - Development session connection established via local.rdr.tpagent.io:53102
21:01:45.244 [main] ERROR io.testproject.java.sdk.v2.Runner - Failed to execute codeblock class TestPrjPackage.AirboneTimeThreshold
java.lang.NullPointerException: null
   at org.openqa.selenium.remote.RemoteWebDriver.findElement(RemoteWebDriver.java:402) ~[io.testproject.sdk.java.jar:na]
   at io.appium.java_client.DefaultGenericMobileDriver.findElement(DefaultGenericMobileDriver.java:58) ~[io.testproject.sdk.java.jar:na]
   at io.appium.java_client.AppiumDriver.findElement(AppiumDriver.java:1) ~[io.testproject.sdk.java.jar:na]
   at io.appium.java_client.android.AndroidDriver.findElement(AndroidDriver.java:1) ~[io.testproject.sdk.java.jar:na]
   at io.testproject.java.sdk.v2.Runner.execute(Runner.java:189) [io.testproject.sdk.java.jar:na]
   at io.testproject.java.sdk.v2.Runner.run(Runner.java:448) [io.testproject.sdk.java.jar:na]
   at io.testproject.java.sdk.v2.Runner.run(Runner.java:386) [io.testproject.sdk.java.jar:na]
   at TestPrjPackage.ElementActionRunner.main(ElementActionRunner.java:20) [bin/:na]

Below my java code :
Class AirboneTimeThreshold
Code
package TestPrjPackage;
import java.util.List;

import org.openqa.selenium.By;

import io.appium.java_client.android.AndroidElement;
import io.testproject.java.annotations.v2.ActionParameter;
import io.testproject.java.annotations.v2.ElementAction;
import io.testproject.java.sdk.v2.addons.AndroidElementAction;
import io.testproject.java.sdk.v2.addons.helpers.AndroidAddonHelper;
import io.testproject.java.sdk.v2.enums.ExecutionResult;

@ElementAction(name = "Airbone Time Threshold")
public class AirboneTimeThreshold implements AndroidElementAction {
@ActionParameter
public List<AndroidElement> AirTimeList;
public String AirxPath = "//android.widget.FrameLayout[1]/android.widget.LinearLayout[1]/android.widget.FrameLayout[1]/android.widget.FrameLayout[1]/android.widget.FrameLayout[1]/android.support.v4.widget.DrawerLayout[1]/android.widget.FrameLayout[1]/android.widget.FrameLayout[1]/android.widget.LinearLayout[1]/android.widget.FrameLayout[1]/android.widget.FrameLayout[1]/android.widget.FrameLayout[1]/android.view.ViewGroup[1]/android.support.v7.widget.RecyclerView[1]/android.widget.FrameLayout[2]/android.widget.LinearLayout[1]/android.view.ViewGroup[1]";

public ExecutionResult execute(AndroidAddonHelper helper,
AndroidElement element) {
// TODO Auto-generated method stub
//io.testproject.java.sdk.v2.drivers.AndroidDriver<AndroidElement> driver = helper.getDriver();
AirTimeList = helper.getDriver().findElements(By.xpath(AirxPath));
//System.out.print(AirTimeList.toString());
return null;
}

}

Class ElementActionRunner:
Code
package TestPrjPackage;

import io.testproject.java.sdk.v2.Runner;

public class ElementActionRunner {
// Setting the development token
   private final static String devToken = "zk3Y9sf_bV5qvY86XeajQ2s19gllgvlHfgIU-ABRXcE1";
   public static void main(String[] args) throws Exception {

       // Running the test using TestProjectRunner
       try (Runner runner = new Runner(devToken, SessionHelper.getDriverSettings())) {

           // Create Action
       AirboneTimeThreshold action =  new AirboneTimeThreshold();
;

           // Run action
           runner.run(action);

       } catch (Throwable e) {
           e.printStackTrace();
           // TODO: Handle debug failure...
       }
   }
}

The testing app is KAYAK and and want to get elements as image below :
https://drive.google.com/file/d/1WXvBDBU5PYE8syvH-1ScU4iplTbPHkC0/view?usp=sharing
« Last Edit: July 30, 2018, 16:17:49 pm by sonha »

Re: Can not execute ElementActionRunner
« Reply #1 on: July 30, 2018, 17:07:25 pm »
Hi,

You should be using an overload of the
Code
run
that accepts
Code
By
as a second parameter.
Also, element action should not be searching for the element, but instead use the provided element in execute() method parameters.

Thanks.

Re: Can not execute ElementActionRunner
« Reply #2 on: August 01, 2018, 17:00:22 pm »
Thankyou. Understood, the runner is ran now

 

Sitemap 1 2 3 4 5 6 7 8