Forum Discussion

pforbes's avatar
pforbes
New Contributor
10 years ago

How do I create a Groovy script to integrate with Selenium?

I am currently doing a proof of concept for automated testing of SOAP and REST services and in some of the test steps I need to navigate to a URL and perform some actions so I knew I could create a Groozy script and utilise Selenium.  So I read the documentation here:

http://readyapi.smartbear.com/features/integration/selenium/introduction

and followed everything to the letter buy I am not having any success.  I made some modifications to try the different drivers and log errors so as it stands my code is as follows:

 

import org.openqa.selenium.By;
import org.openqa.selenium.WebDriver;
import org.openqa.selenium.WebElement;
import org.openqa.selenium.firefox.FirefoxDriver;
import org.openqa.selenium.chrome.ChromeDriver;
import org.openqa.selenium.ie.InternetExplorerDriver;

try {
    log.info("create FirefoxDriver object");
    WebDriver driver;
    driver = new FirefoxDriver();
    driver.get("http://www.google.com");
} catch (Exception e) {
    log.error(e.message);
    driver = null;
}

try {
    log.info("create ChromeDriver object");
    WebDriver driver;
    //System.setProperty("webdriver.chrome.driver", "C:\\DevTools\\Selenium\\chromedriver.exe");
    driver = new ChromeDriver();
    driver.get("http://www.google.com");
} catch (Exception e) {
    log.error(e.message);
    driver = null;
}

try {    
    log.info("create InternetExplorerDriver object");
    WebDriver driver;
    //System.setProperty("webdriver.ie.driver", "C:\\DevTools\\Selenium\\IEDriverServer.exe");    
    driver = new InternetExplorerDriver();
    driver.get("http://www.google.com");    
} catch (Exception e) {
    log.error(e.message);
    driver = null;
}

 

I have commented out the System.setProperty lines because I have added the location to the enviroment variable PATH.

 

For the Firefox driver I get an error which includes:

<p>The following error was encountered while trying to retrieve the URL: <a href="http://127.0.0.1:7055/hub/session">http://127.0.0.1:7055/hub/session</a></p>

 

For Chrome I get the following:

 

Tue Nov 03 13:52:57 GMT 2015:ERROR:Could not start a new session. Possible causes are invalid address of the remote server or browser start-up failure.
Build info: version: '2.48.2', revision: '41bccdd', time: '2015-10-09 19:55:52'
System info: host: '', ip: '', os.name: 'Windows 7', os.arch: 'amd64', os.version: '6.1', java.version: '1.8.0_65'
Driver info: driver.version: ChromeDriver

 

For Internet Explorer I get the following:

 

Tue Nov 03 13:53:17 GMT 2015:ERROR:Could not start a new session. Possible causes are invalid address of the remote server or browser start-up failure.
Build info: version: '2.48.2', revision: '41bccdd', time: '2015-10-09 19:55:52'
System info: host: '', ip: '', os.name: 'Windows 7', os.arch: 'amd64', os.version: '6.1', java.version: '1.8.0_65'
Driver info: driver.version: InternetExplorerDriver

 

I have searched online for possible solutions but everything I have seen doesn't work. Can anyone offer any advice on how to get Selenium working with Ready! API?

 

  • Hello,

     

    Can you please make sure that the jar file was installed correctly and that Ready API actually picked it up. You can confirm this by restarting Ready API and taking a look at the Ready API log on the bottom left of the tool. This log will display all the jars that were loaded. If it is, we may need to take a further look at this issue.

    • pforbes's avatar
      pforbes
      New Contributor

      Hi,

       

      I can confirm I the selenium jars have been loaded:

       

      Wed Nov 04 10:02:38 GMT 2015:INFO:Adding [C:\Program Files\SmartBear\ReadyAPI-1.4.1\bin\ext\selenium-java-2.48.2-srcs.jar] to extensions classpath
      Wed Nov 04 10:02:38 GMT 2015:INFO:Adding [C:\Program Files\SmartBear\ReadyAPI-1.4.1\bin\ext\selenium-java-2.48.2.jar] to extensions classpath

      • GillerM's avatar
        GillerM
        Staff

        Hi pforbes,

         

        It looks like all of the selenium raised errors are regarding the access to the URL: "http://127.0.0.1:7055/hub/session"

         

        1. Can you access that page manually?

        2. Can you access that page via Selenium script outside of Ready! API?