Deploying Selenium IDE exports (JUnit 4 [Webdriver]) to Selenium Grid for parallel tests

classic Classic list List threaded Threaded
18 messages Options
Reply | Threaded
Open this post in threaded view
|

Deploying Selenium IDE exports (JUnit 4 [Webdriver]) to Selenium Grid for parallel tests

Brandon
This post was updated on .
CONTENTS DELETED
The author has deleted this message.
Reply | Threaded
Open this post in threaded view
|

Re: Deploying Selenium IDE exports (JUnit 4 [Webdriver]) to Selenium Grid for parallel tests

softwaretestingforum
Administrator
Hi Brandon,

Welcome to the group. A couple of pointers -

1. I guess you used Eclipse or Intellij to execute test on one machine to make sure tests indeed work. Did you?

2. I suppose you are using Grid1, I suggest you to use Grid 2
Grid 2 wiki describes how you can set up tests to run on multiple environments. Let us know if you face and specific problem with Grid 2.

3. I also suggest you to use TestNG and not Junit as TestNG supports parallel execution of test inherently which I am doubtful in case of JUnit

Hope this helps.


~ seleniumtests.com
Reply | Threaded
Open this post in threaded view
|

Re: Deploying Selenium IDE exports (JUnit 4 [Webdriver]) to Selenium Grid for parallel tests

Brandon
Hi tarunkumar! Thank you for taking the time to answer my questions!!

Ahh.. No, I have not tested to see if they work. By "somewhat new" I mean I just started with automation as a whole less than four months ago, so forgive me if my terminology is poor. I have a background in games QA and have always used a hands-on method, but have recently started working in web QA. Anyway... :D

I'll do some research into testng and grid2. I have eclipse, but I haven't used it much. I presume I need the TestNG plugin to perform the tests prior to deploying them to the grid?

I really appreciate you taking the time to help me out :D
Reply | Threaded
Open this post in threaded view
|

Re: Deploying Selenium IDE exports (JUnit 4 [Webdriver]) to Selenium Grid for parallel tests

softwaretestingforum
Administrator
Hi Brandon,

You could refer these doc for configuration of Selenium in Eclipse/Intellij -

http://seleniumhq.org/docs/appendix_installing_java_driver_client.html

Also since you are beginning with Selenium I would suggest to use Selenium 2 APIs (Also known as WebDriver API) as they are far stable than Selenium 1 APIs (also known as Selenium RC)

~ seleniumtests.com
Reply | Threaded
Open this post in threaded view
|

Re: Deploying Selenium IDE exports (JUnit 4 [Webdriver]) to Selenium Grid for parallel tests

Brandon
This post was updated on .
Edit :

Okay, with your help I may have figured this out! Stay tuned!!

Thank you again!!

Very grateful,

-brandon

Second Edit of the Second Edit:

Okay, I'm starting to see the pieces of the puzzle... Pardon my frustration earlier :D
Reply | Threaded
Open this post in threaded view
|

Re: Deploying Selenium IDE exports (JUnit 4 [Webdriver]) to Selenium Grid for parallel tests

softwaretestingforum
Administrator
Good to know :) Let us know if you face any more issues.
~ seleniumtests.com
Reply | Threaded
Open this post in threaded view
|

Re: Deploying Selenium IDE exports (JUnit 4 [Webdriver]) to Selenium Grid for parallel tests

Brandon
This post was updated on .
CONTENTS DELETED
The author has deleted this message.
Reply | Threaded
Open this post in threaded view
|

Re: Deploying Selenium IDE exports (JUnit 4 [Webdriver]) to Selenium Grid for parallel tests

Brandon
This post was updated on .
CONTENTS DELETED
The author has deleted this message.
Reply | Threaded
Open this post in threaded view
|

Re: Deploying Selenium IDE exports (JUnit 4 [Webdriver]) to Selenium Grid for parallel tests

Brandon
This post was updated on .
*Edit: Apologies for deleting the above posts. I normally never delete posts, however I have found a way around the problem which led me to a whole new set of problems...haha. :) I'll figure it out eventually. Still confused about below, however!*

This is more on topic. I'm still confused as to how to take my IDE tests that I've exported as TestNG (Webdriver) files and get them to run on the grid :(

So, let's assume that I have a test case that I have exported from Selenium IDE as a TestNG (Webdriver) file titled : O13Registration.java. Lets also assume that I have tested the test in Eclipse and no errors are returned.

On my headless Ubuntu server, I have started the hub via the linux command line:

java -jar selenium-server-standalone.2.21.0.jar role -hub

On my Windows machine, I have started a node via the command line:

java -jar selenium-server-standalone-2.21.0.jar -role node -port 5556 -hub http://<hub address>:4444/grid/register


So, I have the hub and one node running. Now what? How do I get my test with the filename O13Registration.java to run on the grid? This is the wall that I'm stuck at.

Is it something as simple as?:

java -jar selenium-server-standalone-2.21.0.jar role -node -browser browserName=firefox,maxinstances=5,platform=WINDOWS -file O13Registration.java

Please help!!

Thank you very much!

Regards,

Brandon



Reply | Threaded
Open this post in threaded view
|

Re: Deploying Selenium IDE exports (JUnit 4 [Webdriver]) to Selenium Grid for parallel tests

Brandon
This post was updated on .
Aside from my question above, here is a link for my latest issue when trying to run the tests in Eclipse. I feel like I'm incredibly close. It includes the test I'm running and the output from the console in Eclipse.

https://gist.github.com/1999151


Line 7 [public class NewO13STAGING extends SeleneseTestBase] was originally [public class NewO13STAGING extends SeleneseTestNgHelper] (brackets for emphasis), but it was throwing up an error ("SeleneseTestNgHelper cannot be resolved to a type").
Reply | Threaded
Open this post in threaded view
|

Re: Deploying Selenium IDE exports (JUnit 4 [Webdriver]) to Selenium Grid for parallel tests

softwaretestingforum
Administrator
In reply to this post by Brandon
Having set up hub, you need to direct your test to use hub mechanism as described here - http://code.google.com/p/selenium/wiki/Grid2

Refer section - Using grid to run tests, which describes -

Since you are on Selenium 1, you should use -

Selenium selenium = new DefaultSelenium(“localhost”, 4444, “*firefox”, “http://www.google.com”);

here localhost and 4444 are hub URL and port.

About the error available in your gist, it is null pointer exception from line -
selenium.open("/");
Have you instantiated selenium object before using it?
~ seleniumtests.com
Reply | Threaded
Open this post in threaded view
|

Re: Deploying Selenium IDE exports (JUnit 4 [Webdriver]) to Selenium Grid for parallel tests

Brandon
Yeah, I read that. I feel exceptionally dim for having to ask, but what do they mean by this? - "For the Selenium 1 RC nodes, you can continue to use the DefaultSelenium object and pass in the hub information:"

Like this?

java -jar selenium-server-standalone.2.21.0.jar role -hub Selenium selenium = new DefaultSelenium(“localhost”, 4444, “*firefox”, “http://www.google.com”);

Reply | Threaded
Open this post in threaded view
|

Re: Deploying Selenium IDE exports (JUnit 4 [Webdriver]) to Selenium Grid for parallel tests

softwaretestingforum
Administrator
Don't feel dim, ask whatever you face problem with :)

It is referring to place where you instantiate selenium object. But having a look at your gist it looks like you are not instantiating it, which is why you encounter null pointer exception . Hence use it as -

@Test public void O13RegStaging() throws Exception {
                Selenium selenium = new DefaultSelenium(“localhost”, 4444, “*firefox”, “http://www.google.com”);
                selenium.open("your URL here");
                selenium.click("id=play_now_glow");
                selenium.waitForPageToLoad("30000");
                selenium.click("css=img.sweety_button");
                selenium.type("id=user_user_profile_attributes_first_name", "QA");
                selenium.type("id=user_use
..
.
.
.


Or better, you can move selenium object instantiation to a common class and annotate it with @Before (if you are on Junit) like -

public class SelTestCase {

     protected Selenium selenium;

    @Before
     public void setup() {
      Selenium selenium = new DefaultSelenium(“localhost”, 4444, “*firefox”, “http://www.google.com”);
      selenium.start();
     }

   @After
     public void setup() {
      selenium.close();
     }
}


Now you test class can extend it and you get the selenium object -

public class NewO13STAGING extends SelTestCase {
        @Test public void O13RegStaging() throws Exception {
                selenium.open("/");
                selenium.click("id=play_now_glow");
                selenium.waitForPageToLoad("30000");
..
..
.
}

 

Remember in line -

new DefaultSelenium(“localhost”, 4444, “*firefox”, “http://www.google.com”);

localhost and 4444 should refer to your hub host and port
~ seleniumtests.com
Reply | Threaded
Open this post in threaded view
|

Re: Deploying Selenium IDE exports (JUnit 4 [Webdriver]) to Selenium Grid for parallel tests

Brandon
This post was updated on .
tarunkumar, can I tell you that I love you? Because I do. True story. In all seriousness, thank you very much for being so helpful.

I have completely ditched using JUnit and have since adopted TestNG.

This is the newest latest. I have the grid up and running with one node. When running my test as a TestNG test, I'm seeing the following:

https://gist.github.com/1999151

FTA -

FAILED: O13RegStaging
com.thoughtworks.selenium.SeleniumException: Connection refused: connect
at com.thoughtworks.selenium.HttpCommandProcessor.executeCommandOnServlet(HttpCommandProcessor.java:107)
at com.thoughtworks.selenium.HttpCommandProcessor.doCommand(HttpCommandProcessor.java:86)
at com.thoughtworks.selenium.DefaultSelenium.open(DefaultSelenium.java:335)
at com.example.tests.NewO13STAGING.O13RegStaging(NewO13STAGING.java:10)
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:57)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
.....
....


Do I have to use the WebDriver instead of Selenium in order to run it from Eclipse? Or both?
IE -
WebDriver driver = new RemoteWebDriver(new URL("http://seleniumgrid:4444/wd/hub"), capability);



Edit::

I DID IT. I DID IT. Okay... I think I'm going to write a tut for people like me - People who want to learn, but don't have the coding background to make it happen.

I simply copied an example project, and with some help made a superclass to replace the SeleniumTestNGhelper (which seemed to be causing a lot of problems for me) class.

Now, I'm trying to deploy them in parallel. I have it such that when I run the script, it will fire up Firefox, perform the test, and close the browser.

I've amended the following line to read as follows to deploy to chrome and firefox, but it's only opening up Firefox :

 @BeforeClass
         public void startSelenium() {
         
          this.selenium = new DefaultSelenium("localhost", Integer.parseInt("4444"), "*firefox, *chrome", "http://XXXXXXXXX.com");
                this.selenium.start();
                this.selenium.open("http://XXXXXXXXX.com");

Any suggestions on how to make this work?
Reply | Threaded
Open this post in threaded view
|

Re: Deploying Selenium IDE exports (JUnit 4 [Webdriver]) to Selenium Grid for parallel tests

softwaretestingforum
Administrator
Brandon I love all Selenium users :)
Also thanks for showing interests in posting your questions on the site.

Now coming to using Google Chrome, you can instantiate Google Chrome as -

 this.selenium = new DefaultSelenium("localhost", Integer.parseInt("4444"),  *googlechrome", "http://sweetyhigh.com");

Notice that DefaultSelenium construct takes only 4 arguments. This is the list of browsers you can use.

  *firefox
  *mock
  *firefoxproxy
  *pifirefox
  *chrome
  *iexploreproxy
  *iexplore
  *firefox3
  *safariproxy
  *googlechrome
  *konqueror
  *firefox2
  *safari
  *piiexplore
  *firefoxchrome
  *opera
  *iehta
  *custom

The reason I ask to use Selenium 2 (also known as WebDriver API) is that soon you would find that you Selenium RC commands which work in FF don't work in IE or chrome, or you may run in to permission denied error when using Selenium RC.
While you would never face permission denied error with WebDriver API, click, type etc operations are also almost identical so you face mush less issues with Selenium  2 than with Selenium 1 (also known as Selenium RC)

If you need a small tutorial on using Selenium 2 then this might help -
http://www.seleniumtests.com/2012/01/selenium-2-methods-are-no-more-weird.html

It's little long but I have tried to compare how Selenium 2 API can be structured just like Selenium 1 and more maintainable tests could be written.

~ seleniumtests.com
Reply | Threaded
Open this post in threaded view
|

Re: Deploying Selenium IDE exports (JUnit 4 [Webdriver]) to Selenium Grid for parallel tests

Brandon
Yeah, I'm getting the errors. I've resorted to trying to write an AutoIt script that runs in the background to kill those auto auth windows, but of course I'm having trouble with that :D hehe...

I read your blog post that you linked, thank you for that. It appears that I won't be able to export my Selenium IDE cases like I am now, or can I? Either way, I suppose I should start learning how to write them out.

P.S. - Would you mind terribly removing the link of the URL I referenced in your reply above? I didn't mean to include it in the post.

Thank you again for everything :D

-brandon
Reply | Threaded
Open this post in threaded view
|

Re: Deploying Selenium IDE exports (JUnit 4 [Webdriver]) to Selenium Grid for parallel tests

softwaretestingforum
Administrator
So are you able to use Google Chrome now?
About editing your past post, I can only delete a post but can not edit it. Silly permissions.
~ seleniumtests.com
Reply | Threaded
Open this post in threaded view
|

Re: Deploying Selenium IDE exports (JUnit 4 [Webdriver]) to Selenium Grid for parallel tests

Tanya
In reply to this post by Brandon
Hi Brandon,

I started learning Selenium very recently and after getting stuck with another problem I try to research online to get answers. After reading your post I figured that I'm being the same shoe as you were few months back. You mentioned that you're going to write a tut for people like you, I am like you. :) Did you get a chance to write something up? Can you share?

I’m using Grid2 and I have tests sitting in Ecslipse now and I run them via TestNG (Webdriver).  
I have started the hub on one box and the node on another box via the command line. Both boxes are Windows server (planning to move to the Linux box)
I added these lines inside my tests:
DesiredCapabilities capability = DesiredCapabilities.firefox();

WebDriver driver = new RemoteWebDriver(new URL("http://localhost:4444/wd/hub"), capability);

Now how does my test supposed to run? Any clues?

Thanks!