Quantcast
Channel: New board topics in SmartBear Community
Viewing all articles
Browse latest Browse all 20755

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

$
0
0

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?

 


Viewing all articles
Browse latest Browse all 20755

Latest Images

Trending Articles



Latest Images