Selenide + TestNG + Selenium Grid

408 views
Skip to first unread message

Maxime Feraud

unread,
May 9, 2016, 9:58:58 AM5/9/16
to selenide
Hi !

I'm trying to set up Selenide to my Selenium test tools.
Actually, i'm using Selenium, test in Java using TestNG Framework, and run them in Virtual Machines using Selenium grid.

When I try to run my Selenide test, i've got this error :

org.testng.TestNGException:
Cannot instantiate class popgom.global.CommandeFittingCBTest
    at org.testng.internal.ObjectFactoryImpl.newInstance(ObjectFactoryImpl.java:38)
    at org.testng.internal.ClassHelper.createInstance1(ClassHelper.java:387)
    at org.testng.internal.ClassHelper.createInstance(ClassHelper.java:299)
    at org.testng.internal.ClassImpl.getDefaultInstance(ClassImpl.java:110)
    at org.testng.internal.ClassImpl.getInstances(ClassImpl.java:186)
    at org.testng.internal.TestNGClassFinder.<init>(TestNGClassFinder.java:120)
    at org.testng.TestRunner.initMethods(TestRunner.java:409)
    at org.testng.TestRunner.init(TestRunner.java:235)
    at org.testng.TestRunner.init(TestRunner.java:205)
    at org.testng.TestRunner.<init>(TestRunner.java:160)
    at org.testng.remote.support.RemoteTestNG6_5$1.newTestRunner(RemoteTestNG6_5.java:26)
    at org.testng.remote.support.RemoteTestNG6_5$DelegatingTestRunnerFactory.newTestRunner(RemoteTestNG6_5.java:59)
    at org.testng.SuiteRunner$ProxyTestRunnerFactory.newTestRunner(SuiteRunner.java:561)
    at org.testng.SuiteRunner.init(SuiteRunner.java:157)
    at org.testng.SuiteRunner.<init>(SuiteRunner.java:111)
    at org.testng.TestNG.createSuiteRunner(TestNG.java:1273)
    at org.testng.TestNG.createSuiteRunners(TestNG.java:1260)
    at org.testng.TestNG.runSuitesLocally(TestNG.java:1114)
    at org.testng.TestNG.run(TestNG.java:1031)
    at org.testng.remote.AbstractRemoteTestNG.run(AbstractRemoteTestNG.java:126)
    at org.testng.remote.RemoteTestNG.initAndRun(RemoteTestNG.java:137)
    at org.testng.remote.RemoteTestNG.main(RemoteTestNG.java:58)
Caused by: java.lang.reflect.InvocationTargetException
    at sun.reflect.NativeConstructorAccessorImpl.newInstance0(Native Method)
    at sun.reflect.NativeConstructorAccessorImpl.newInstance(NativeConstructorAccessorImpl.java:62)
    at sun.reflect.DelegatingConstructorAccessorImpl.newInstance(DelegatingConstructorAccessorImpl.java:45)
    at java.lang.reflect.Constructor.newInstance(Constructor.java:423)
    at org.testng.internal.ObjectFactoryImpl.newInstance(ObjectFactoryImpl.java:29)
    ... 21 more
Caused by: java.lang.NullPointerException: key can't be null
    at java.lang.System.checkKey(System.java:838)
    at java.lang.System.getProperty(System.java:714)
    at popgom.global.CommandeFittingCBTest.<init>(CommandeFittingCBTest.java:71)
    ... 26 more


Here is my code? I'm doing something wrong, but how to run my test on my VM with Selenide ?


public class CommandeFittingCBTest {

    public String remote = System.getProperty(URL OF MY NODE);

    @Test
    public void CommandeFittingCB() throws InterruptedException, IOException {

    open("http://MYWEBSITE");
    $(By.xpath("//p/a/img")).click();
    $(By.xpath("//div[2]/div[2]/div/div/div/a/span")).waitUntil(present, 5000);
    $(By.xpath("//div[2]/div[2]/div/div/div/a/span")).click();
    $(By.xpath("//div[@id='cboxLoadedContent']/div/div[3]/a[2]/span")).waitUntil(present, 5000);
    $(By.xpath("//div[@id='cboxLoadedContent']/div/div[3]/a[2]/span")).click();
    $(By.xpath("//div[@id='deliveryTypePremiumButton']/a/span")).waitUntil(present, 5000);
    $(By.xpath("//div[@id='deliveryTypePremiumButton']/a/span")).click();
    $(By.xpath("//input[@id='addressField']")).waitUntil(present, 5000);
    $(By.xpath("//input[@id='addressField']")).setValue("01000");
    $(By.xpath("//div[2]/a/div")).click();
    $(By.xpath("//td[5]/div/a/span")).click();
    $(By.xpath("//div[2]/a/span")).waitUntil(present, 5000);
    $(By.xpath("//div[2]/a/span")).click();
    $(By.id("logEmailField")).waitUntil(present, 5000);
    $(By.id("logEmailField")).setValue("ferau...@gmail.com");
    $(By.id("logPwdField")).setValue("leamax");
    $(By.xpath("//div[7]/div/div[2]/div/div[5]/a/span")).click();
    $(By.xpath("//div[@id='loggedAccountFormCgv']/input")).waitUntil(present, 5000);
    $(By.xpath("//div[@id='loggedAccountFormCgv']/input")).waitUntil(enabled, 5000);
    $(By.xpath("//div[@id='loggedAccountFormCgv']/input")).click();
    $(By.xpath("//div[3]/a/span")).click();
    $(By.xpath("//select[@id='cardType-CARD']")).waitUntil(present, 5000);
    $(By.xpath("//select[@id='cardType-CARD']")).selectOption("EUROCARD/MASTERCARD");
    $(By.xpath("//div[2]/input")).setValue("feraud");
    $(By.xpath("//div[5]/div/div[2]/input")).setValue("1111222233334444");
    $(By.xpath("//select[@id='monthField-CARD']")).selectOption("01");
    $(By.xpath("//select[@id='yearField-CARD']")).selectOption("2018");
    $(By.xpath("//div[9]/div/div[2]/input")).setValue("123");
    $(By.xpath("//div[5]/div[2]/a")).click();

Thanks for help

Andrei Solntsev

unread,
May 9, 2016, 6:02:41 PM5/9/16
to Maxime Feraud, selenide
Hi Maxime!
It seems that error happens in this line:

public String remote = System.getProperty(URL OF MY NODE);

and it happens because you are passing NULL parameter to method System.getProperty().
In other words, URL OF MY NODE is null.

Andrei Solntsev

--
You received this message because you are subscribed to the Google Groups "selenide" group.
To unsubscribe from this group and stop receiving emails from it, send an email to selenide+u...@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

Message has been deleted

Maxime Feraud

unread,
May 10, 2016, 3:59:24 AM5/10/16
to selenide, ferau...@gmail.com
Hi, and thanks for your help !

I've insert directly the url of my node in the public String remote = System.getProperty

No error at all, but the test continue to be run on my host instead of my VM.

Am i doing something wrong in my test configuration ?How do I need to configure my @BeforeTest to make this configuration works ?

Thanks for helping

Andrei Solntsev

unread,
May 12, 2016, 6:28:33 PM5/12/16
to Maxime Feraud, selenide
If I understand correctly, you are using this line in your code:

String remote = System.getProperty("URL OF MY NODE");

But "get" method is for reading, it doesn't modify any url.
Try to set the property: 

System.setProperty("URL OF MY NODE", "http://your-domain.com");

Andrei Solntsev

2016-05-10 10:55 GMT+03:00 Maxime Feraud <ferau...@gmail.com>:
Hi, and thanks for your help !

I've insert directly the url of my node in the public String remote = System.getProperty

No error at all, but the test continue to be run on my host instead of my VM.

Am i doing something wrong in my test configuration ?

--

Maxime Feraud

unread,
May 13, 2016, 3:49:27 AM5/13/16
to selenide, ferau...@gmail.com
Ok ok,

And then, how do I have to configure the test to make this configuration works ? 

do a :        open(remote); ? 

i'm a bit lost. Do I need, in plus of the System.setProperty("URL OF MY NODE", "http://your-domain.com");
do something more ? 

Thanks for Help 

Andrei Solntsev

unread,
May 18, 2016, 4:30:44 PM5/18/16
to Maxime Feraud, selenide
Hi Maxime!
I am lost lost, because I don't see your code. I don't even imagine how do you initialize all that constants.

Anyway, the simplest working code is the following:

public class CommandeFittingCBTest {


    @Test
    public void CommandeFittingCB() throws InterruptedException, IOException {
       System.setProperty("remote", "http://localhost:5678/hub");
      open("http://MYWEBSITE");
      $(By.xpath("//p/a/img")).click();
      ...
  }

Andrei Solntsev

Maxime Feraud

unread,
May 19, 2016, 3:22:35 AM5/19/16
to selenide, ferau...@gmail.com
Thanks !

This works perfectly for Firefox on my VM.

How to deal with other navigator now ? 

I've try to use :

      System.setProperty("selenide.browser", "chrome");

As you should in a forum, but I've got an error :

org.openqa.seleium.WebDriverException: The best matcing driver provider org.openqa.selenium.edge.EdgeDriver can't create a new instance.

So I try to indicate the path ( in my VM ) to the chromedriver; 

      System.setProperty("webdriver.chrome.driver", "C:\\PATH\\TO\\Chromedriver");

without success, still got the same error. Any idea?

Thanks once again


Maxime Feraud

Andrei Solntsev

unread,
May 19, 2016, 5:09:47 AM5/19/16
to Maxime Feraud, selenide
This is unknown error for me. 
I guess you are initializing webdriver somehow incorrectly. 
I guess you set some "edge" property somewhere, that's why webdriver tries to initialize Edge browser.

Andrei Solntsev

Maxime Feraud

unread,
May 19, 2016, 5:52:45 AM5/19/16
to selenide, ferau...@gmail.com
I clean my test following you're advice and now i've got an other error.

The test " cannot find the Chrome binary " 

Damn it !

Andrei Solntsev

unread,
May 19, 2016, 6:30:57 AM5/19/16
to Maxime Feraud, selenide

Actually it's a good news, you are almost there. Now you just need to install Chrome browser. :)

--

Maxime Feraud

unread,
May 19, 2016, 8:50:58 AM5/19/16
to selenide, ferau...@gmail.com
Perfect it's working !

Is this method can works for the Chromium navigator ? 

Andrei Solntsev

unread,
May 19, 2016, 9:45:33 AM5/19/16
to Maxime Feraud, selenide
Good!
Yes, it should work with chromium too.

Andrei Solntsev

2016-05-19 15:50 GMT+03:00 Maxime Feraud <ferau...@gmail.com>:
Perfect it's working !

Is this method can works for the Chromium navigator ? 

--

Maxime Feraud

unread,
May 19, 2016, 9:51:35 AM5/19/16
to selenide, ferau...@gmail.com
I've tried and it's not working in my VM with chromium, even when I specified the path to the chromium.exe

How would you do ? 

Andrei Solntsev

unread,
May 19, 2016, 10:45:27 AM5/19/16
to Maxime Feraud, selenide

I don't know exactly, I personally haven't tried it. Try to google it - this problem is not Selenide specific.

On May 19, 2016 4:51 PM, "Maxime Feraud" <ferau...@gmail.com> wrote:
I've tried and it's not working in my VM with chromium, even when I specified the path to the chromium.exe

How would you do ? 

--
Reply all
Reply to author
Forward
0 new messages