0

I'm trying to execute headless browser script using the following Selenium script from SoapUI - Groovy script step.

import org.openqa.selenium.By;
import org.openqa.selenium.WebDriver;
import org.openqa.selenium.WebElement;
import org.openqa.selenium.htmlunit.HtmlUnitDriver;
import com.gargoylesoftware.htmlunit.BrowserVersion;

loginApp()

public void loginApp()
{
    HtmlUnitDriver driver = new HtmlUnitDriver(BrowserVersion.CHROME);  
    driver.setJavascriptEnabled(true);
    driver.get("MyURL")
    driver.manage().timeouts().implicitlyWait(120,TimeUnit.SECONDS);

    driver.findElement(By.id("username")).sendKeys("1234567");
    driver.findElement(By.id("password")).sendKeys("1234567");
    driver.findElement(By.id("submit")).submit();
    driver.manage().timeouts().implicitlyWait(120,TimeUnit.SECONDS);
    log.info("Page title is: " + driver.getTitle());
}

And it's throwing the following error message in the SoapUI console.

Mon May 21 17:46:32 IST 2018:ERROR:groovy.lang.MissingPropertyException: No such property: CHROME for class: com.gargoylesoftware.htmlunit.BrowserVersion
   groovy.lang.MissingPropertyException: No such property: CHROME for class: com.gargoylesoftware.htmlunit.BrowserVersion
    at groovy.lang.MetaClassImpl.invokeStaticMissingProperty(MetaClassImpl.java:900)
    at groovy.lang.MetaClassImpl.getProperty(MetaClassImpl.java:1678)
    at groovy.lang.MetaClassImpl.getProperty(MetaClassImpl.java:1654)
    at groovy.lang.MetaClassImpl.getProperty(MetaClassImpl.java:3407)
    at org.codehaus.groovy.runtime.callsite.ClassMetaClassGetPropertySite.getProperty(ClassMetaClassGetPropertySite.java:48)
    at org.codehaus.groovy.runtime.callsite.AbstractCallSite.callGetProperty(AbstractCallSite.java:227)
    at Script8.loginApp(Script8.groovy:12)
    at Script8.run(Script8.groovy:8)
    at com.eviware.soapui.support.scripting.groovy.SoapUIGroovyScriptEngine.run(SoapUIGroovyScriptEngine.java:92)
    at com.eviware.soapui.impl.wsdl.teststeps.WsdlGroovyScriptTestStep.run(WsdlGroovyScriptTestStep.java:141)
    at com.eviware.soapui.impl.wsdl.panels.teststeps.GroovyScriptStepDesktopPanel$RunAction$1.run(GroovyScriptStepDesktopPanel.java:250)
    at java.util.concurrent.ThreadPoolExecutor.runWorker(Unknown Source)
    at java.util.concurrent.ThreadPoolExecutor$Worker.run(Unknown Source)
    at java.lang.Thread.run(Unknown Source)

But the the same script is running perfectly normal browser automation i.e. if I remove the following line and added....

Added:

System.setProperty("webdriver.chrome.driver","D:\\SoapUI-5.2.1\\bin\\ext\\chromedriver.exe")
WebDriver driver = new ChromeDriver(); 

Removed:

HtmlUnitDriver driver = new HtmlUnitDriver(BrowserVersion.CHROME);

I have placed the supporting JAR files in the SoapUI/bin/ext folder.

- selenium-server-standalone-3.4.0
- chromedriver 2.39
- selenium-htmlunit-driver-2.51.0

So, I have googled but no luck to solve my issue. Anyone help me to resolve it?

Thanks,
Karunagara Pandi

Karunagara
  • 389
  • 1
  • 8
  • 30
  • Check this discussion https://stackoverflow.com/questions/50273474/unable-to-launch-htmlunitdriver-through-selenium-3-4-0/50274121#50274121 – undetected Selenium May 21 '18 at 12:40
  • I'm getting this error if I use default constructor of HtmlUnitDriver: java.lang.NoSuchMethodError: com.gargoylesoftware.htmlunit.WebClient.getOptions()Lcom/gargoylesoftware/htmlunit/WebClientOptions; error at line: 8 – Karunagara May 21 '18 at 13:12
  • Remove `com.gargoylesoftware.htmlunit.` completely, clean you _Work Space_ from your IDE and execute – undetected Selenium May 21 '18 at 13:14
  • You mean to say, import org.openqa.selenium.htmlunit.HtmlUnitDriver; this should be removed from the script? – Karunagara May 21 '18 at 13:18
  • `import org.openqa.selenium.htmlunit.HtmlUnitDriver;` is required but remove `com.gargoylesoftware.htmlunit.*` – undetected Selenium May 21 '18 at 13:20
  • No luck Debanjan...I'm getting the same error message which I had mentioned above even I removed selenium-htmlunit-driver-2.51.0 from the SoapUI installation path. :(. I have kept only "selenium-server-standalone-3.4.0" in the SoapUI installation path. – Karunagara May 21 '18 at 13:28
  • You need to clean up the workspace from your IDE. Use [CCleaner](https://www.ccleaner.com/ccleaner) to wipe off all the os chores. – undetected Selenium May 21 '18 at 13:32
  • Any other option to resolve this issue as in our office there are lot of process to install that tool in my machine. – Karunagara May 21 '18 at 13:35

0 Answers0