bs00336332 / robotframework-seleniumlibrary

Automatically exported from code.google.com/p/robotframework-seleniumlibrary
Apache License 2.0
0 stars 0 forks source link

Ability to provide additional options to selenium java process #242

Closed GoogleCodeExporter closed 9 years ago

GoogleCodeExporter commented 9 years ago
Please add ability to provide custom options to java process which runs 
Selenium Server. 

Proposed patch - it uses environment variable. I've used SELENIUM_JAVA_OPTS for 
environment variable name because JAVA_OPTS may be too generic.

Index: SeleniumLibrary/__init__.py
===================================================================
--- SeleniumLibrary/__init__.py (wersja 15373)
+++ SeleniumLibrary/__init__.py (kopia robocza)
@@ -82,7 +82,10 @@
     if not jarpath:
         jarpath = SELENIUM_SERVER_PATH
     params = _add_default_user_extension(jarpath, list(params))
-    java_opts = os.environ['SELENIUM_JAVA_OPTS'].split(' ')
+    if 'SELENIUM_JAVA_OPTS' in os.environ:
+        java_opts=os.environ['SELENIUM_JAVA_OPTS'].split(' ')
+    else:
+        java_opts=[]
     return ['java'] +  java_opts + [ '-jar', jarpath] + _server_startup_params(params)

 def _add_default_user_extension(jarpath, params):

Original issue reported on code.google.com by chmielss...@gmail.com on 21 Jun 2012 at 1:46

GoogleCodeExporter commented 9 years ago
Start Selenium Server already accepts *params, which can be used to pass 
arbitrary command line options to Selenium Server startup.

Is there a reason you cannot use that?

Original comment by janne.t....@gmail.com on 6 Aug 2012 at 10:21

GoogleCodeExporter commented 9 years ago
As I understant *params provides custom command line options to Selenium server 
and I need a custom options to java process which runs Selenium server:
java <my options> -jar jarpath  + _server_startup_params(params)

which can be seen at the bottom of my patch above.
I needed this to route all traffic through proxy to log all HTTP requests and 
responses.

Original comment by chmielss...@gmail.com on 6 Aug 2012 at 12:28

GoogleCodeExporter commented 9 years ago
Correct patch:
--- SeleniumLibrary/__init__.py (wersja 15373)
+++ SeleniumLibrary/__init__.py (kopia robocza)
@@ -82,7 +82,10 @@
     if not jarpath:
         jarpath = SELENIUM_SERVER_PATH
     params = _add_default_user_extension(jarpath, list(params))
+    if 'SELENIUM_JAVA_OPTS' in os.environ:
+        java_opts=os.environ['SELENIUM_JAVA_OPTS'].split(' ')
+    else:
+        java_opts=[]
     return ['java'] +  java_opts + [ '-jar', jarpath] + _server_startup_params(params)

 def _add_default_user_extension(jarpath, params):

Original comment by chmielss...@gmail.com on 6 Aug 2012 at 2:21

GoogleCodeExporter commented 9 years ago
You are correct, I read the patch too fast.

I still do not think that configuring some things via keyword arguments and 
others via environment variables is the best possible approach.

Unfortunately, it is also quite difficult to change the signature of 
start_selenium_server without backwards incompatibility issues. One option 
could be to accept some special name in *params, but that's quite obscure too.

I'll think about this a bit, but something will definitely be done.

Original comment by janne.t....@gmail.com on 6 Aug 2012 at 5:12

GoogleCodeExporter commented 9 years ago
Going to fix this by adding special check in Start Selenium Server for argument 
named JVM.

So, after the fix, this will work:

Start Selenium Server   JVM=-Dsomething   --ensureCleanSession

which translates to

java -Dsomething selenium-server.jar -ensureCleanSession

Original comment by janne.t....@gmail.com on 27 Aug 2012 at 1:07

GoogleCodeExporter commented 9 years ago
This issue was updated by revision 5dbeb11bdbd9.

Original comment by janne.t....@gmail.com on 28 Aug 2012 at 4:55