Forum Discussion

RaghavanG's avatar
RaghavanG
Occasional Contributor
4 months ago
Solved

Create Selenium Tests in ReadyAPI

How to Create Selenium Tests in ReadyAPI?. Getting error. Not sure where it went wrong.

I followed the steps in below link.

https://support.smartbear.com/readyapi/docs/integrations/selenium/integrate.html

Getting below error when I have tried sample code in Groovy scripts.

Snippet:

import org.openqa.selenium.firefox.FirefoxDriver;
import org.openqa.selenium.WebElement;
import org.openqa.selenium.By;

System.setProperty("webdriver.chrome.driver", "C:/Program Files/SmartBear/ReadyAPI-3.42.1/bin/ext/chromedriver.exe");

def driver = new ChromeDriver()

// Navigate to the ReadyAPI documentation
driver.get("https://support.smartbear.com/readyapi/docs/")

// Enter the search string
def searchbox = driver.findElement(By.id("inputSearchBox"));
searchbox.sendKeys("Groovy");

// Command to search for the typed text
def searchbtn = driver.findElement(By.id("btnSearch"));
searchbtn.click();

// List suggestions
def allSuggestions = driver.findElements(By.xpath("//div[@id='search_results_container']/div/h5/a"))
for (def suggestion : allSuggestions)
{
if(suggestion.getAttribute('href') != '')
log.info(suggestion.getAttribute('href'))
else
log.error('The test failed.')
}
// Close the browser
driver.quit();

 

Error:

 

org.codehaus.groovy.control.MultipleCompilationErrorsException: startup failed:
Script4.groovy: 7: unable to resolve class ChromeDriver
@ line 7, column 14.
def driver = new ChromeDriver()
^
org.codehaus.groovy.syntax.SyntaxException: unable to resolve class ChromeDriver
@ line 7, column 14.

 

  • Hello RaghavanG 

     

    If you choose to deviate from the steps described in the instructions, you will need to be prepared for the ramifications...  🙂

     

    You have replaced some firefox values that were defined in the instructions with chrome values.  It looks like you need to change line:

       import org.openqa.selenium.firefox.FirefoxDriver;

    to:

       import org.openqa.selenium.chrome.ChromeDriver;

    in order to overcome your current condition.  After that is done, you may encounter further errors.  I have not debugged your code beyond what jumps out at me.  🙂

     

    Regards,

    Todd

     

2 Replies

  • Hello RaghavanG 

     

    If you choose to deviate from the steps described in the instructions, you will need to be prepared for the ramifications...  🙂

     

    You have replaced some firefox values that were defined in the instructions with chrome values.  It looks like you need to change line:

       import org.openqa.selenium.firefox.FirefoxDriver;

    to:

       import org.openqa.selenium.chrome.ChromeDriver;

    in order to overcome your current condition.  After that is done, you may encounter further errors.  I have not debugged your code beyond what jumps out at me.  🙂

     

    Regards,

    Todd