How to pass custom options to Chrome WebDriver using selenium plugin?

code
how-to
#1

So the question is: how to pass custom options to Chrome WebDriver using selenium plugin? When I use this code I’m getting error: The path to the driver executable must be set by the webdriver.chrome.driver system property but I don’t know where it is installed driver on RPA instance. I should set it by capability plugin? I tried:

<capability name="plugins.plugins_disabled" value="['Adobe Flash Player', 'Chrome PDF Viewer']"></capability>
<capability name="plugins.always_open_pdf_externally" value="true"></capability>

but I’m not sure if it works properly with ChromeOptions. I would like to disable PDF viewer in Chrome and instead download it as file. Thanks in advance :wink:

ChromeOptions options = new ChromeOptions()
Map<String, Object> preferences = new Hashtable<String, Object>()
options.setExperimentalOption("prefs", preferences)
// disable flash and the PDF viewer
preferences.put("plugins.plugins_disabled", ["Adobe Flash Player", "Chrome PDF Viewer"])
				
driver = new ChromeDriver(preferences)
1 Like
#2

Hi, @wojciech_soltys
try to use capability like bellow:

<capability name="chromeOptions">
<script return="chromeArgs">
	<![CDATA[
	import org.openqa.selenium.chrome.ChromeOptions;
	import java.util.Map;
	import java.util.Hashtable;
		
	ChromeOptions options = new ChromeOptions()
               Map preferences = new Hashtable()
               options.setExperimentalOption("prefs", preferences)
               // disable flash and the PDF viewer
               preferences.put("plugins.plugins_disabled", ["Adobe Flash Player", "Chrome PDF Viewer"])
	chromeArgs = options;
]]></script>
</capability>

	<script><![CDATA[
		open("http://cnn.com"); 
		sleep(20000);
	]]></script>

Best Regards
Kanstantsin Sheleh

2 Likes