How can I debug Test and run it locally in my IDE?

  • 14 Replies
  • 1363 Views
How can I debug Test and run it locally in my IDE?
« on: July 20, 2018, 09:04:51 am »
Hello, I have read the description on github here:
https://github.com/testproject-io/java-sdk-examples/tree/master/Web

It says:
Quote
Runner Project
To debug or run the test locally, you need a Runner:

Create a new project
Reference TestProject SDK.
Reference the project of your test.
Create a runnable class.
Invoke your test from the Runner project.


But I have no idea how to do all this stuff...
Can you please give some basic explanation that helps me get started?

Thanks!
« Last Edit: August 07, 2018, 17:00:14 pm by Marat Strelets »

*

Gil

  • *
  • 3
Hello jaki,

In order to run some test, you need to use the Runner object.
Please look at the following file:
https://github.com/testproject-io/java-sdk-examples/blob/master/Web/Runners/src/main/java/io/testproject/examples/sdk/java/TestRunner.java

The following line:
Code
try (Runner runner = new Runner(devToken, driverSettings)) { 

Create an instance of Runner object.
The instance contains a method called run(..).
This method gets in its first parameter an instance of the test. I our case the test is "BasicTest" that can be found here:
https://github.com/testproject-io/java-sdk-examples/blob/master/Web/Test/src/main/java/io/testproject/examples/sdk/java/tests/BasicTest.java

We pass the instance of the test to the run() method of the Runner object:
Code
 runner.run(test); 

Then, the method will run the test locally on without testproject platform.

When you run the test on testproject platform, there is no need for the Runner object.
because testproject platform have it's own run mechanism for running test so that it call directly to the entry point of the test (The execute function). 


We recommend you to download the example and use it as a template for your tests.

We hope it helped you to get started.

If you have more questions, you are welcome to ask!

Good luck!

HI I have done  above settings, also set devToken path here   private final static String devToken = "";
I have install agent and its running.


but  when I am running the 'TestRunner.java' I am getting below error
21:42:17.919 [main] DEBUG io.testproject.java.sdk.v2.Runner - Starting development session...
21:42:20.414 [main] ERROR io.testproject.java.sdk.v2.Runner - Failed to connect to https://local.rdr.tpagent.io:8443, Agent is running?
java.lang.InstantiationException: Failed to start development session!
   at io.testproject.java.sdk.v2.Runner.<init>(Runner.java:161)
   at io.testproject.java.sdk.v2.Runner.<init>(Runner.java:121)
   at io.testproject.examples.sdk.java.ActionRunner.main(ActionRunner.java:19)


I have open https://local.rdr.tpagent.io:8443 path on my browser its showing as

 TestProject Agent (0.41.26) on akash-Lenovo-ideapad-320-15IKB (Linux)

Installation path: /home/akash/testproject/agent

Data path: /home/akash/.testproject/agent

IPs: 192.168.0.107

Registered: Yes (6674)

Authorized: Yes (mZTVVsc9FkKjcSNkObK5IQ)

Alias: Agent001


Please help me how we can solve this.

What is the JDK version you use? Please make sure you are using JDK 8. you can find it bundled with the Agent under JRE folder

yes I am using java 8 only
[email protected]:~/Downloads$ javac -version
javac 1.8.0_171

I download project from github, set dev key , set java sdk then try to run the project.
do i need to change more setting?
I am running this in ubuntu 16.04.


« Last Edit: July 27, 2018, 20:44:13 pm by akashrathod8 »

Are you using an IDE? If so, which one?
Can you try running the following curl command from terminal?
Replace YOUR_DEV_TOKEN with actual token.

Code
curl --request POST \
  --url https://local.rdr.tpagent.io:8443/api/development/session \
  --header 'Accept: application/json' \
  --header 'Authorization: YOUR_DEV_TOKEN' \
  --header 'Cache-Control: no-cache' \
  --header 'Content-Type: application/json' \
  --header 'Postman-Token: 9f6fd82c-c619-4929-9487-5bef3a0e0399' \
  --data '{\n  "driverSettings": {\n    "mobileSettings": null,\n    "desiredCapabilties": null,\n    "desiredCapabilitiesObject": null,\n    "mobile": false,\n    "type": "Chrome"\n  },\n  "sdkVersion": "0.41.0"\n}'

What is the response status code ?
Thanks.

I am using Eclipse,
I run above curl command , result I got : {"status":405,"code":500,"source":null,"message":"Application error occurred during the request processing, please try again"}
..
The Curl Command I used
 
Code
curl --request post--url https://local.rdr.tpagent.io:8443/api/development/session   --header 'Accept: application/json'   --header 'Authorization:  Ds9WipbhLfcIlnem4LNxzNRloBz8Mt9YnM3CHmQ_l9k1'   --header 'Cache-Control: no-cache'   --header 'Content-Type: application/json'   --header 'Postman-Token: 9f6fd82c-c619-4929-9487-5bef3a0e0399'   --data '{\n  "driverSettings": {\n    "mobileSettings": null,\n    "desiredCapabilties": null,\n    "desiredCapabilitiesObject": null,\n    "mobile": false,\n    "type": "Chrome"\n  },\n  "sdkVersion": "0.41.0"\n}'

Also I have created JAR for same and uploaded to TestProject platform it is working fine.
« Last Edit: July 28, 2018, 07:56:19 am by akashrathod8 »

Hi,

Can you please send me via email (to this address: [email protected]) your Agent logs?
You can find them here:
~/.testproject/agent/logs

Thank you!

Thanks for the reply,
I have sent you the mail.

Thank you. I received it.
We will review this issue and get back to you ASAP.


I am using Eclipse,
I run above curl command , result I got : {"status":405,"code":500,"source":null,"message":"Application error occurred during the request processing, please try again"}
..
The Curl Command I used
 
Code
curl --request post--url https://local.rdr.tpagent.io:8443/api/development/session   --header 'Accept: application/json'   --header 'Authorization:  Ds9WipbhLfcIlnem4LNxzNRloBz8Mt9YnM3CHmQ_l9k1'   --header 'Cache-Control: no-cache'   --header 'Content-Type: application/json'   --header 'Postman-Token: 9f6fd82c-c619-4929-9487-5bef3a0e0399'   --data '{\n  "driverSettings": {\n    "mobileSettings": null,\n    "desiredCapabilties": null,\n    "desiredCapabilitiesObject": null,\n    "mobile": false,\n    "type": "Chrome"\n  },\n  "sdkVersion": "0.41.0"\n}'

Also I have created JAR for same and uploaded to TestProject platform it is working fine.

Error you get does not make sense, please try again using the command attached after replacing YOUR_DEV_TOKEN with your token.

hi I have tried this attached command with YOUR_DEV_TOKEN change
 
Code
curl --request POST \
  --url https://local.rdr.tpagent.io:8443/api/development/session \
  --header 'Accept: application/json' \
  --header 'Authorization: Ds9WipbhLfcIlnem4LNxzNRloBz8Mt9YnM3CHmQ_l9k1' \
  --header 'Cache-Control: no-cache' \
  --header 'Content-Type: application/json' \
  --header 'Postman-Token: 56b92afa-35f2-41fb-91a0-0a863f50e6b0' \
  --data '{  "driverSettings": {    "mobileSettings": null,    "desiredCapabilties": null,    "desiredCapabilitiesObject": null,    "mobile": false,    "type": "Chrome"  },  "sdkVersion": "0.41.0"}'

and got below response

{"status":500,"code":0,"source":"ServerError","message":"Application error occurred during the request processing, please try again"}
Then I tried with change in type: as Firefox
the I got response as

{"capabilities":{"capabilities":{"moz:profile":"/tmp/rust_mozprofile.dwurzjEvQLiU","rotatable":false,"timeouts":{"implicit":0.0,"pageLoad":300000.0,"script":30000.0},"pageLoadStrategy":"normal","moz:headless":false,"platform":"ANY","moz:accessibilityChecks":false,"moz:useNonSpecCompliantPointerOrigin":false,"webdriver.remote.sessionid":"f99e41d4-9c99-4acb-b37f-677adfac092d","acceptInsecureCerts":true,"browserVersion":"61.0.1","platformVersion":"4.15.0-29-generic","moz:processID":11212.0,"browserName":"firefox","takesScreenshot":true,"javascriptEnabled":true,"platformName":"linux","cssSelectorsEnabled":true,"moz:webdriverClick":true}},"dialect":"OSS","devSocketPort":32931,"testManagerGuid":"e074bdfd-6ac8-499b-a3e3-d15e49e09a7f","serverAddress":"http://127.0.0.1:43397/wd/hub","sessionId":"f99e41d4-9c99-4acb-b37f-677adfac092d"}

please help to understand this




I wanted to verify that Agent API is accessible.

First request fails since you have no Chrome installed.
Second with type: Firefox works fine.

Can you please share you Runner source? Do you specify Chrome or Firefox in driverSettings?

hi,  yes I did specify Firefox browser here
find below runner source file
Code
package runner;
import Test.GoogleTest;
import io.testproject.java.classes.DriverSettings;
import io.testproject.java.enums.DriverType;
import io.testproject.java.sdk.v2.Runner;
public class TestRunner {
    // Setting the development token
    private final static String devToken = "Ds9WipbhLfcIlnem4LNxzNRloBz8Mt9YnM3CHmQ_l9k1";

    public static void main(String[] args) throws Exception {
        // Creating driver settings to be used when running the test
        DriverSettings driverSettings = new DriverSettings(DriverType.Firefox);

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

            // Create test
            GoogleTest test = new GoogleTest();
            test.name = "John Smith";
            test.country = "United States";
            // Run test
            runner.run(test);
        } catch (Throwable e) {
            e.printStackTrace();
            // TODO: Handle debug failure...
        }
    }
}

help on this
« Last Edit: August 01, 2018, 16:32:57 pm by akashrathod8 »

Re: How can I debug Test and run it locally in my IDE?
« Reply #14 on: August 07, 2018, 17:01:40 pm »
Locked due to inactivity.

 

Sitemap 1 2 3 4 5 6 7 8