0

I have a website and I just wanna write a script to send strings to a text input on the page (the only one) and click submit. I had a selenium one built but was told that was overkill it was much "easier" to access the endpoint on the page and send the text that way.

I was advised to use the Jersey client for this.

import org.glassfish.jersey.client.*;
import org.glassfish.jersey.client.JerseyWebTarget;
import javax.ws.rs.client.Client;
import javax.ws.rs.client.WebTarget; 
import javax.ws.rs.core.Response;
import org.glassfish.jersey.client.JerseyClientBuilder;

public class mqDirect {

public static void main (String args[])
{

    String baseUrl = "URL";   // removed real url herebut it is properlink
    Client client = JerseyClientBuilder.createClient();

    WebTarget target = client.target(baseUrl);
    Response response = target.request().get();

    System.out.print("response is : " + response);

 }
}

I have been looking at examples and this code compiles, but I just wanted to see what the actual response in this case is and when I run it I get the error

Exception in thread "main" java.lang.IllegalStateException: InjectionManagerFactory not found. atorg.glassfish.jersey.internal.inject.Injections.lambda$lookupInjectionManag erFactory$0(Injections.java:98) at java.util.Optional.orElseThrow(Optional.java:290)

So to send a text string to the text input on the page do I use .post() method? I feel selenium was a lot easier for this, if not so pretty ...

Jayendran
  • 9,638
  • 8
  • 60
  • 103
Liam
  • 19
  • 2
  • 5

1 Answers1

0

I used dependency :

        <dependency>
            <groupId>org.glassfish.jersey.core</groupId>
            <artifactId>jersey-client</artifactId>
            <version>2.16</version>
        </dependency>

and it is working fine with that :
Maybe you should change your dependency version.
Hope that helps you:)

dangi13
  • 1,275
  • 1
  • 8
  • 11