How to pass custom options to Chrome WebDriver using selenium plugin in RPA Express?

This works in workfusion SPA, now this needs to get replicated in workfusion express. The error I am getting is org.selenium.WebDriverException: com.google.gson.internal.LinkedTreeMap cannot be cast to org.openqa.selenium.ChromeOptions

Hi Aneesh, could you post the script you are trying to execute here?
Also, which versions of RPA Express and Control Tower are you using?

Thank you.

Hi Alesia, here is the bot task xml that I am trying to use

<?xml version="1.0" encoding="UTF-8"?>
<config xmlns="http://web-harvest.sourceforge.net/schema/1.0/config" scriptlang="groovy">
<robotics-flow>
    <robot driver="universal" close-on-completion="false" start-in-private="false">
        <capability name="SEARCH_ALL_WINDOWS" value="true">
            <script return="chromeArgs"><![CDATA[
                    import org.openqa.selenium.chrome.ChromeOptions;
                    ChromeOptions options = new ChromeOptions();
                    options.setExperimentalOption("useAutomationExtension",false);
                    chromeArgs = options;
                           ]]></script>
        </capability>
        <script><![CDATA[
                import com.workfusion.studio.rpa.recorder.api.*
                import com.workfusion.studio.rpa.recorder.api.types.*
                import com.workfusion.studio.rpa.recorder.api.custom.*
                import com.workfusion.studio.rpa.recorder.api.internal.representation.*
                enableTypeOnScreen()
               timeouts().pageLoadTimeout(10000, java.util.concurrent.TimeUnit.MILLISECONDS)
                openChrome(UrlOperations.ensureProtocol("www.google.co.za"))
           ]]></script>
    </robot>
</robotics-flow>
</config>

Thanks. Which version of RPA Express are you using?

Sunbird 1.4.0

@aneesh.chandran,
you have incorrect capabilities,
i think you want to set up 2 capabilities:
SEARCH_ALL_WINDOWS
and
chromeOptions

it should looks like:

<?xml version="1.0" encoding="UTF-8"?>
<config xmlns="http://web-harvest.sourceforge.net/schema/1.0/config" scriptlang="groovy">
<robotics-flow>
    <robot driver="universal" close-on-completion="false" start-in-private="false">
        <capability name="SEARCH_ALL_WINDOWS" value="true"/>
        <capability name="chromeOptions">
            <script return="chromeArgs"><![CDATA[
                    import org.openqa.selenium.chrome.ChromeOptions;
                    ChromeOptions options = new ChromeOptions();
                    options.setExperimentalOption("useAutomationExtension",false);
                    chromeArgs = options;
                           ]]></script>
        </capability>
        <script><![CDATA[
                import com.workfusion.studio.rpa.recorder.api.*
                import com.workfusion.studio.rpa.recorder.api.types.*
                import com.workfusion.studio.rpa.recorder.api.custom.*
                import com.workfusion.studio.rpa.recorder.api.internal.representation.*
                enableTypeOnScreen()
               timeouts().pageLoadTimeout(10000, java.util.concurrent.TimeUnit.MILLISECONDS)
                openChrome(UrlOperations.ensureProtocol("www.google.co.za"))
           ]]></script>
    </robot>
</robotics-flow>
</config>
1 Like

The error I am getting when I run the chrome options above are:

Step name ‘Chrome 666’ has failed. Reason: '[urn:uuid:68643F62FAB2D425B315255392755107] robotics-flow executePlugin exception: [nodeId=http://127.0.0.1:15410] org.webharvest.exception.ScriptException:
Config line 14: script block
org.openqa.selenium.WebDriverException: com.google.gson.internal.LinkedTreeMap cannot be cast to org.openqa.selenium.chrome.ChromeOptions
Command duration or timeout: 0 milliseconds
Build info: version: ‘8.5.1’, revision: ‘87eae3e04f’, time: ‘2018-03-14T11:03:21.319Z’
System info: host: ‘2494JNBPBB56L’, ip: ‘192.168.56.1’, os.name: ‘Windows 7’, os.arch: ‘amd64’, os.version: ‘6.1’, java.version: ‘1.8.0_121’
Driver info: com.freedomoss.crowdcontrol.webharvest.selenium.wrapper.RemoteDriverWrapper
Capabilities [{capabilityNodeId=http://127.0.0.1:15410, extra.executor.id={run.name=Business Process 05/05/2018 16:52:30, task.uuid=853aacc4-3a3d-49c3-a75b-e1d05ab225a0, task.name=Chrome 666, context.path=/workfusion, host.name=http://localhost:15280, run.author.emai…org.webharvest.exception.PluginException: [urn:uuid:68643F62FAB2D425B315255392755107] robotics-flow executePlugin exception: [nodeId=http://127.0.0.1:15410] org.webharvest.exception.ScriptException:
Config line 14: script block
org.openqa.selenium.WebDriverException: com.google.gson.internal.LinkedTreeMap cannot be cast to org.openqa.selenium.chrome.ChromeOptions
Command duration or timeout: 0 milliseconds
Build info: version: ‘8.5.1’, revision: ‘87eae3e04f’, time: ‘2018-03-14T11:03:21.319Z’
System info: host: ‘2494JNBPBB56L’, ip: ‘192.168.56.1’, os.name: ‘Windows 7’, os.arch: ‘amd64’, os.version: ‘6.1’, java.version: ‘1.8.0_121’
Driver info: com.freedomoss.crowdcontrol.webharvest.selenium.wrapper.RemoteDriverWrapper
Capabilities [{capabilityNodeId=http://127.0.0.1:15410, extra.executor.id={run.name=Business Process 05/05/2018 16:52:30, task.uuid=853aacc4-3a3d-49c3-a75b-e1d05ab225a0, task.name=Chrome 666, context.path=/workfusion, host.name=http://localhost:15280, run.author.email=john@doe.ex, run.uuid=853aacc4-3a3d-49c3-a75b-e1d05ab225a0, run.author.fullname=John Doe}, browserName=universal, maximize.on.startup=true, javascriptEnabled=true, extra.capabilities.context={“browserType”:“universal”,“startInPrivate”:false,“blockImages”:false,“nodeId”:“http://127.0.0.1:15410”,“maximizeOnStartup”:true,“customCapabilities”:{“chromeOptions”:{“args”:[],“extensionFiles”:[],“extensions”:[],“experimentalOptions”:{“useAutomationExtension”:false},“capabilities”:{“caps”:{}}},“SEARCH_ALL_WINDOWS”:“true”},“executorId”:{“host.name”:“http://localhost:15280”,“context.path”:"/workfusion",“task.uuid”:“853aacc4-3a3d-49c3-a75b-e1d05ab225a0”,“run.name”:“Business Process 05/05/2018 16:52:30”,“run.uuid”:“853aacc4-3a3d-49c3-a75b-e1d05ab225a0”,“run.author.fullname”:“John Doe”,“run.author.email”:“john@doe.ex”,“task.name”:“Chrome 666”}}, chromeOptions={args=[], extensions=[], useAutomationExtension=false}, platformName=WINDOWS, SEARCH_ALL_WINDOWS=true, platform=WINDOWS}]
Session ID: 8ad78c7b-6db4-49f5-a12b-4b502dedbaa2
at com.freedomoss.crowdcontrol.webharvest.plugin.selenium.RoboticsFlowPlugin.executePlugin(RoboticsFlowPlugin.java:116)
at org.webharvest.runtime.processors.WebHarvestPlugin.execute(WebHarvestPlugin.java:125)
at org.webharvest.runtime.processors.BaseProcessor.run(BaseProcessor.java:127)
at org.webharvest.runtime.Scraper.execute(Scraper.java:169)
at org.webharvest.runtime.Scraper.execute(Scraper.java:182)
at com.freedomoss.crowdcontrol.webharvest.executor.LocalWebharvestTaskExecutor.executeWebHarvestTask(LocalWebharvestTaskExecutor.java:182)
at com.freedomoss.crowdcontrol.webharvest.executor.LocalWebharvestTaskExecutor.executeWebHarvestTask(LocalWebharvestTaskExecutor.java:93)
at com.workfusion.service.machine.BotRecordExecutionService.process(BotRecordExecutionService.java:186)
at com.workfusion.service.machine.BotRecordExecutionService.process(BotRecordExecutionService.java:157)
at com.workfusion.service.machine.BotRecordExecutionService.processSubmissionWithAllocationLogger(BotRecordExecutionService.java:136)
at com.workfusion.service.machine.BotRecordExecutionService.lambda$processRecord$14(BotRecordExecutionService.java:115)
at com.workfusion.utils.thread.NamedThreadTemplate.executeWithNamedThread(NamedThreadTemplate.java:10)
at com.workfusion.service.machine.BotRecordExecutionService.processRecord(BotRecordExecutionService.java:115)
at com.workfusion.service.machine.thread.RecordProcessThread.run(RecordProcessThread.java:28)
at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1142)
at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:617)
at java.lang.Thread.run(Thread.java:745)
Caused by: org.webharvest.exception.PluginException: org.webharvest.exception.ScriptException:
Config line 14: script block
org.openqa.selenium.WebDriverException: com.google.gson.internal.LinkedTreeMap cannot be cast to org.openqa.selenium.chrome.ChromeOptions
Command duration or timeout: 0 milliseconds
Build info: version: ‘8.5.1’, revision: ‘87eae3e04f’, time: ‘2018-03-14T11:03:21.319Z’
System info: host: ‘2494JNBPBB56L’, ip: ‘192.168.56.1’, os.name: ‘Windows 7’, os.arch: ‘amd64’, os.version: ‘6.1’, java.version: ‘1.8.0_121’
Driver info: com.freedomoss.crowdcontrol.webharvest.selenium.wrapper.RemoteDriverWrapper
Capabilities [{capabilityNodeId=http://127.0.0.1:15410, extra.executor.id={run.name=Business Process 05/05/2018 16:52:30, task.uuid=853aacc4-3a3d-49c3-a75b-e1d05ab225a0, task.name=Chrome 666, context.path=/workfusion, host.name=http://localhost:15280, run.author.email=john@doe.ex, run.uuid=853aacc4-3a3d-49c3-a75b-e1d05ab225a0, run.author.fullname=John Doe}, browserName=universal, maximize.on.startup=true, javascriptEnabled=true, extra.capabilities.context={“browserType”:“universal”,“startInPrivate”:false,“blockImages”:false,“nodeId”:“http://127.0.0.1:15410”,“maximizeOnStartup”:true,“customCapabilities”:{“chromeOptions”:{“args”:[],“extensionFiles”:[],“extensions”:[],“experimentalOptions”:{“useAutomationExtension”:false},“capabilities”:{“caps”:{}}},“SEARCH_ALL_WINDOWS”:“true”},“executorId”:{“host.name”:“http://localhost:15280”,“context.path”:"/workfusion",“task.uuid”:“853aacc4-3a3d-49c3-a75b-e1d05ab225a0”,“run.name”:“Business Process 05/05/2018 16:52:30”,“run.uuid”:“853aacc4-3a3d-49c3-a75b-e1d05ab225a0”,“run.author.fullname”:“John Doe”,“run.author.email”:“john@doe.ex”,“task.name”:“Chrome 666”}}, chromeOptions={args=[], extensions=[], useAutomationExtension=false}, platformName=WINDOWS, SEARCH_ALL_WINDOWS=true, platform=WINDOWS}]
Session ID: 8ad78c7b-6db4-49f5-a12b-4b502dedbaa2
at com.freedomoss.crowdcontrol.webharvest.plugin.selenium.RobotPlugin.executePlugin(RobotPlugin.java:194)
at org.webharvest.runtime.processors.WebHarvestPlugin.execute(WebHarvestPlugin.java:125)
at org.webharvest.runtime.processors.BaseProcessor.run(BaseProcessor.java:127)
at org.webharvest.runtime.processors.BodyProcessor.execute(BodyProcessor.java:27)
at org.webharvest.runtime.processors.WebHarvestPlugin.executeBody(WebHarvestPlugin.java:246)
at com.freedomoss.crowdcontrol.webharvest.plugin.selenium.RoboticsFlowPlugin.executePlugin(RoboticsFlowPlugin.java:105)
… 16 more
Caused by: org.webharvest.exception.ScriptException:
Config line 14: script block
org.openqa.selenium.WebDriverException: com.google.gson.internal.LinkedTreeMap cannot be cast to org.openqa.selenium.chrome.ChromeOptions
Command duration or timeout: 0 milliseconds
Build info: version: ‘8.5.1’, revision: ‘87eae3e04f’, time: ‘2018-03-14T11:03:21.319Z’
System info: host: ‘2494JNBPBB56L’, ip: ‘192.168.56.1’, os.name: ‘Windows 7’, os.arch: ‘amd64’, os.version: ‘6.1’, java.version: ‘1.8.0_121’
Driver info: com.freedomoss.crowdcontrol.webharvest.selenium.wrapper.RemoteDriverWrapper
Capabilities [{capabilityNodeId=http://127.0.0.1:15410, extra.executor.id={run.name=Business Process 05/05/2018 16:52:30, task.uuid=853aacc4-3a3d-49c3-a75b-e1d05ab225a0, task.name=Chrome 666, context.path=/workfusion, host.name=http://localhost:15280, run.author.email=john@doe.ex, run.uuid=853aacc4-3a3d-49c3-a75b-e1d05ab225a0, run.author.fullname=John Doe}, browserName=universal, maximize.on.startup=true, javascriptEnabled=true, extra.capabilities.context={“browserType”:“universal”,“startInPrivate”:false,“blockImages”:false,“nodeId”:“http://127.0.0.1:15410”,“maximizeOnStartup”:true,“customCapabilities”:{“chromeOptions”:{“args”:[],“extensionFiles”:[],“extensions”:[],“experimentalOptions”:{“useAutomationExtension”:false},“capabilities”:{“caps”:{}}},“SEARCH_ALL_WINDOWS”:“true”},“executorId”:{“host.name”:“http://localhost:15280”,“context.path”:"/workfusion",“task.uuid”:“853aacc4-3a3d-49c3-a75b-e1d05ab225a0”,“run.name”:“Business Process 05/05/2018 16:52:30”,“run.uuid”:“853aacc4-3a3d-49c3-a75b-e1d05ab225a0”,“run.author.fullname”:“John Doe”,“run.author.email”:“john@doe.ex”,“task.name”:“Chrome 666”}}, chromeOptions={args=[], extensions=[], useAutomationExtension=false}, platformName=WINDOWS, SEARCH_ALL_WINDOWS=true, platform=WINDOWS}]
Session ID: 8ad78c7b-6db4-49f5-a12b-4b502dedbaa2
at org.webharvest.runtime.scripting.GroovyScriptEngine.eval(GroovyScriptEngine.java:138)
at org.webharvest.runtime.processors.ScriptProcessor.execute(ScriptProcessor.java:74)
at org.webharvest.runtime.processors.BaseProcessor.run(BaseProcessor.java:127)
at org.webharvest.runtime.processors.BodyProcessor.execute(BodyProcessor.java:27)
at org.webharvest.runtime.processors.WebHarvestPlugin.executeBody(WebHarvestPlugin.java:246)
at com.freedomoss.crowdcontrol.webharvest.plugin.selenium.RobotPlugin.executePlugin(RobotPlugin.java:187)
… 21 more
Caused by: org.openqa.selenium.WebDriverException: com.google.gson.internal.LinkedTreeMap cannot be cast to org.openqa.selenium.chrome.ChromeOptions
Command duration or timeout: 0 milliseconds
Build info: version: ‘8.5.1’, revision: ‘87eae3e04f’, time: ‘2018-03-14T11:03:21.319Z’
System info: host: ‘2494JNBPBB56L’, ip: ‘192.168.56.1’, os.name: ‘Windows 7’, os.arch: ‘amd64’, os.version: ‘6.1’, java.version: ‘1.8.0_121’
Driver info: com.freedomoss.crowdcontrol.webharvest.selenium.wrapper.RemoteDriverWrapper
Capabilities [{capabilityNodeId=http://127.0.0.1:15410, extra.executor.id={run.name=Business Process 05/05/2018 16:52:30, task.uuid=853aacc4-3a3d-49c3-a75b-e1d05ab225a0, task.name=Chrome 666, context.path=/workfusion, host.name=http://localhost:15280, run.author.email=john@doe.ex, run.uuid=853aacc4-3a3d-49c3-a75b-e1d05ab225a0, run.author.fullname=John Doe}, browserName=universal, maximize.on.startup=true, javascriptEnabled=true, extra.capabilities.context={“browserType”:“universal”,“startInPrivate”:false,“blockImages”:false,“nodeId”:“http://127.0.0.1:15410”,“maximizeOnStartup”:true,“customCapabilities”:{“chromeOptions”:{“args”:[],“extensionFiles”:[],“extensions”:[],“experimentalOptions”:{“useAutomationExtension”:false},“capabilities”:{“caps”:{}}},“SEARCH_ALL_WINDOWS”:“true”},“executorId”:{“host.name”:“http://localhost:15280”,“context.path”:"/workfusion",“task.uuid”:“853aacc4-3a3d-49c3-a75b-e1d05ab225a0”,“run.name”:“Business Process 05/05/2018 16:52:30”,“run.uuid”:“853aacc4-3a3d-49c3-a75b-e1d05ab225a0”,“run.author.fullname”:“John Doe”,“run.author.email”:“john@doe.ex”,“task.name”:“Chrome 666”}}, chromeOptions={args=[], extensions=[], useAutomationExtension=false}, platformName=WINDOWS, SEARCH_ALL_WINDOWS=true, platform=WINDOWS}]
Session ID: 8ad78c7b-6db4-49f5-a12b-4b502dedbaa2
at sun.reflect.NativeConstructorAccessorImpl.newInstance0(Native Method)
at sun.reflect.NativeConstructorAccessorImpl.newInstance(NativeConstructorAccessorImpl.java:62)
at sun.reflect.DelegatingConstructorAccessorImpl.newInstance(DelegatingConstructorAccessorImpl.java:45)
at java.lang.reflect.Constructor.newInstance(Constructor.java:423)
at org.openqa.selenium.remote.ErrorHandler.createThrowable(ErrorHandler.java:216)
at org.openqa.selenium.remote.ErrorHandler.throwIfResponseFailed(ErrorHandler.java:168)
at org.openqa.selenium.remote.http.JsonHttpResponseCodec.reconstructValue(JsonHttpResponseCodec.java:41)
at org.openqa.selenium.remote.http.AbstractHttpResponseCodec.decode(AbstractHttpResponseCodec.java:82)
at org.openqa.selenium.remote.http.AbstractHttpResponseCodec.decode(AbstractHttpResponseCodec.java:45)
at org.openqa.selenium.remote.HttpCommandExecutor.execute(HttpCommandExecutor.java:164)
at org.openqa.selenium.remote.RemoteWebDriver.execute(RemoteWebDriver.java:656)
at org.openqa.selenium.remote.RemoteWebDriver.get(RemoteWebDriver.java:370)
at com.workfusion.rpa.helpers.RPA.openChrome(RPA.java:536)
at org.codehaus.groovy.vmplugin.v7.IndyInterface.selectMethod(IndyInterface.java:232)
at Script7_genScript_3.run(Script7_genScript_3.groovy:21)
at groovy.lang.GroovyShell.evaluate(GroovyShell.java:585)
at groovy.lang.GroovyShell.evaluate(GroovyShell.java:623)
at groovy.lang.GroovyShell.evaluate(GroovyShell.java:594)
at org.webharvest.runtime.scripting.GroovyScriptEngine.eval(GroovyScriptEngine.java:136)
… 26 more
Caused by: java.lang.ClassCastException: com.google.gson.internal.LinkedTreeMap cannot be cast to org.openqa.selenium.chrome.ChromeOptions
at com.workfusion.common.browser.ChromeBrowser.addExtraCapabilities(ChromeBrowser.java:15)
at com.workfusion.universal.factory.UniversalDriverFactory.constructDesiredCapabilities(UniversalDriverFactory.java:51)
at com.workfusion.universal.factory.UniversalDriverFactory.createDriver(UniversalDriverFactory.java:37)
at com.workfusion.universal.state.UniversalDriverState.lambda$createWebDriverIfNotExists$25(UniversalDriverState.java:114)
at java.util.HashMap.computeIfAbsent(HashMap.java:1126)
at com.workfusion.universal.state.UniversalDriverState.createWebDriverIfNotExists(UniversalDriverState.java:114)
at com.workfusion.universal.driver.UniversalDriver.get(UniversalDriver.java:44)
at org.openqa.selenium.remote.server.handler.GetBrowser.call(GetBrowser.java:43)
at org.openqa.selenium.remote.server.handler.GetBrowser.call(GetBrowser.java:25)
at org.openqa.selenium.remote.server.handler.WebDriverHandler.handle(WebDriverHandler.java:41)
at org.openqa.selenium.remote.server.rest.ResultConfig.handle(ResultConfig.java:133)
at org.openqa.selenium.remote.server.JsonHttpCommandHandler.handleRequest(JsonHttpCommandHandler.java:202)
at org.openqa.selenium.remote.server.InMemorySession.execute(InMemorySession.java:98)
at org.openqa.selenium.remote.server.WebDriverServlet.lambda$handle$0(WebDriverServlet.java:231)
at java.util.concurrent.Executors$RunnableAdapter.call(Executors.java:511)
at java.util.concurrent.FutureTask.run(FutureTask.java:266)
… 3 more