You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
The website i'm testing has certificates errors as it's a test environment. I can see that PhantomJS has a arg that can be passed to ignore such things "--ignore-ssl-errors=[true|false]". However I can't find how I can pass thing through in selenium2library for it to take affect.
Phantom JS command line args can be passed in using the desired capabilities in Selenium. So just pass in the desired capabilities that you want when you call open browser. probably something like (and I'm doing this from memory so double check the syntax):
Open Browser http://google.com PhantomJS desired_capabilites=ignore-ssl-errors:true
Hope that helps,
Jeremy
On Jun 18, 2013, at 7:45 PM, jbarnes007 wrote:
Hello
The website i'm testing has certificates errors as it's a test environment. I can see that PhantomJS has a arg that can be passed to ignore such things "--ignore-ssl-errors=[true|false]". However I can't find how I can pass thing through in selenium2library for it to take affect.
Any help would be greatly appreciated.
Jules
—
Reply to this email directly or view it on GitHub.
I've tried that and the options don't seem to be passed to phantomjs.exe.
See below.
Also tried passing --ignore-ssl-errors:true but no affect.
11:59:34.469 INFO - Executing: [new session: {platform=ANY,
javascriptEnabled=true, browserName=phantomjs, version=,
ignore-ssl-errors=true}] at URL: /session)
11:59:34.485 INFO - Creating a new session for Capabilities [{platform=ANY,
javascriptEnabled=true, browserName=phantomjs, ignore-ssl-errors=true,
version=}]
11:59:34.516 INFO - executable: C:\Program Files\Selenium
Node\phantomjs\phantomjs.exe
11:59:34.516 INFO - port: 18110
11:59:34.516 INFO - arguments: [--webdriver=18110,
--webdriver-logfile=C:\Program Files\Selenium Node\phantomjsdriver.log]
11:59:34.516 INFO - environment: {}
PhantomJS is launching GhostDriver...
[INFO - 2013-06-19T01:59:36.466Z] GhostDriver - Main - running on port
18110
Phantom JS command line args can be passed in using the desired
capabilities in Selenium. So just pass in the desired capabilities that you
want when you call open browser. probably something like (and I'm doing
this from memory so double check the syntax):
Open Browser http://google.com PhantomJS
desired_capabilites=ignore-ssl-errors:true
Hope that helps,
Jeremy
On Jun 18, 2013, at 7:45 PM, jbarnes007 wrote:
Hello
The website i'm testing has certificates errors as it's a test
environment. I can see that PhantomJS has a arg that can be passed to
ignore such things "--ignore-ssl-errors=[true|false]". However I can't find
how I can pass thing through in selenium2library for it to take affect.
Any help would be greatly appreciated.
Jules
—
Reply to this email directly or view it on GitHub.
—
Reply to this email directly or view it on GitHubhttps://github.com//issues/215#issuecomment-19651687
.
Here's what I have gathered:
The proper way to tell PhantomJS to accept all certs would be to use acceptSslCerts:true, but this capability is marked TODO.
When instantiating a local webdriver, Selenium2Library does not pass desired_capabilities to the constructor (or anything else for that matter). desired_capabilities is documented as such - *If you specify a value for remote you can also specify *...'desired_capabilities'...
@j1z0 Do you know why desired capabilities was never passed to the browser specific constructors and only to the remote webdriver?
So even if Selenium2Library were changed to pass the desired capabilities to the webdriver constructors, jbarnes007 would still be out of luck because acceptSslCerts is not implemented in PhantomJS
I see a few solutions here.
Launch PhantomJS externally, using argument --ignore-ssl-errors=true and then use a remote_url for open_browser
Modify S2L to expose the service_args argument.
Modify S2L to allow the user to put a manually constructed browser into the cache. This is what I did for SudsLibrary.
I was able to add an argument service_args to open_browser and pass that all the way down to _generic_make_browser which I changed to:
def _generic_make_browser(self, webdriver_type , desired_cap_type, remote_url, desired_caps, service_args=None):
'''most of the make browser functions just call this function which creates the
appropriate web-driver'''
if not remote_url:
browser = webdriver_type(service_args=service_args)
...
This allowed me to run a phantomJS this test against a site with a bad cert that otherwise would not load/pass:
${sa}= Create List --ignore-ssl-errors=true
Open Browser https://site-with-bad-cert/ phantomjs service_args=${sa}
Page Should Contain Textfield name=ACCOUNT
Answering my question to Jeremy...
The ability to pass in desired capabilities to the constructor is new for some browsers.
ie from 2.32, called capabilities
firefox from 2.26, called capabilities
opera from initial commit, called desired_capabilities
chrome from 2.8, called desired_capabilities
phantomjs from initial commit, called desired_capabilities
I do not understand why the commiter used a different argument name for the same thing when it was added to IE and Firefox.
The argument is not in the same position for the different webdrivers either :(
Regarding desired capabilities it IS passed into the BROWSER SPECIFIC constructors. But all the BROWSER SPECIFIC constructors just use the default GENERIC CONSTRUCTOR that only forwards desired capabilities to remote browsers.
Sorry for the caps just trying to make it clear, that each browser type has the option to create the browser however they want. This is by design and that way if PhantomJS uses non standard name of service_args then we can just modify the _make_phantomjs function to pass in desired capabilities as service_args and not have to add an additional service_args parameter for all other browsers that they won't need...
Adding one parameter is not a big deal, but if we end up having to add service_args for phantom_js, chrome_options for chrome, etc... etc... it can't get out of hand. So I designed it with the actory pattern to prevent that.
For the bigger question.
When I wrote it you couldn't pass desired capabilities on a local browser. But I think you make a good case that it needs to happen for things like acceptSslCerts now a days.
--edit--
based on your last comment, probably passing in desired_capabilities by keyword in the Generic constructor and overriding it for IE and Firefox... I think also the Chrome guys are talking about changing the name to Chrome_options or something like that (not sure if it will happen though).
Also regarding your suggesting for number 3. to manually construct the browser you would have to do that from code right? I mean there is no way to do it from RF Keywords correct? So what modifications are you suggesting? Because from code you can already put a manually constructed browser into the cache, given that nothing is really private in python. Just trying to understand what your looking for, cause I'm all for making things more flexible.
On Jun 20, 2013, at 12:40 AM, Kevin Ormbrek wrote:
Here's what I have gathered:
The proper way to tell PhantomJS to accept all certs would be to use acceptSslCerts:true, but this capability is marked TODO.
When instantiating a local webdriver, Selenium2Library does not pass desired_capabilities to the constructor (or anything else for that matter). desired_capabilities is documented as such - *If you specify a value for remote you can also specify *...'desired_capabilities'...
@j1z0 Do you know why desired capabilities was never passed to the browser specific constructors and only to the remote webdriver?
So even if Selenium2Library were changed to pass the desired capabilities to the webdriver constructors, jbarnes007 would still be out of luck because acceptSslCerts is not implemented in PhantomJS
I see a few solutions here.
Launch PhantomJS externally, using argument --ignore-ssl-errors=true and then use a remote_url for open_browser
Modify S2L to expose the service_args argument.
Modify S2L to allow the user to put a manually constructed browser into the cache. This is what I did for SudsLibrary.
I was able to add an argument service_args to open_browser and pass that all the way down to _generic_make_browser which I changed to:
def _generic_make_browser(self, webdriver_type , desired_cap_type, remote_url, desired_caps, service_args=None):
'''most of the make browser functions just call this function which creates the
appropriate web-driver'''
if not remote_url:
browser = webdriver_type(service_args=service_args)
...
This allowed me to run a phantomJS this test against a site with a bad cert that otherwise would not load/pass:
${sa}= Create List --ignore-ssl-errors=true
Open Browser https://site-with-bad-cert/ phantomjs service_args=${sa}
Page Should Contain Textfield name=ACCOUNT
—
Reply to this email directly or view it on GitHub.
@jbarnes007 If you are interested in temporary workaround, I posted an example on the RF user group of how to open PhantomJS passing command line arguments. The example is for setting a proxy, but it should be obvious how to use it to ignore bad certs.
@j1z0 What you call constructors I call factory methods. To me, constructors are only new or init methods. What you did is a good design. It is challenging to wrap disparate constructors into one single method. On top of that, the signatures have changed in recent versions.
If PhantomJS fully supported the JsonWireProtocol, the only change we need to make is to have _generic_make_browser pass the DesiredCapabilities on to the browser-specific constructors. Perhaps that is all that should be done.
I think we could use reflection to find out if the init takes a desired_capabilities(or capabilities) argument and raise an error if the desired_capabilities passed to _generic_make_browser is not None and the argument is not present in the constructor (e.g. IE when Se < 2.32)
Chrome's constructor takes service_args, desired_capabilities, and chrome_options :(
As for a nice way to change Open Browser to support those I can't really think of anything. Perhaps an other_args argument that is a keyword argument dict, but that is pretty ugly. Of course so is having to write your own keyword to open the browser. What do you think?
Yes you can add a browser into the cache by accessing private methods. I was more referring to having an endorsed method that users can count on not changing (a PY API if you will) that also does the initial get() and logs session id.
Yes you can add a browser into the cache by accessing private methods. I was more referring to having an >endorsed method that users can count on not changing (a PY API if you will) that also does the initial get() and >logs session id.
Yes good idea, making it public though will expose it to RF, I guess we can just add a docstring saying this is intending for extending S2L and not for being used through RF scripts..
Yes. This is what I did for SudsLibrary. I also covered it in the library documentation.
Another route I never thought of was a separate API class with public methods, but that seems overly complicated.
Yep, as @bmannix, GhostDriver (the WebDriver inside PhantomJS) doesn't support the setting of that capabilty yet.
Unfortunately PhantomJS accepts that only via CLI parameter.
But there is a capability to provide an array of command line parameters: that way you can circumvent the problem for now.
Activity
j1z0 commentedon Jun 19, 2013
Phantom JS command line args can be passed in using the desired capabilities in Selenium. So just pass in the desired capabilities that you want when you call open browser. probably something like (and I'm doing this from memory so double check the syntax):
Open Browser http://google.com PhantomJS desired_capabilites=ignore-ssl-errors:true
Hope that helps,
Jeremy
On Jun 18, 2013, at 7:45 PM, jbarnes007 wrote:
jbarnes007 commentedon Jun 19, 2013
Hello Jeremy
I've tried that and the options don't seem to be passed to phantomjs.exe.
See below.
Also tried passing --ignore-ssl-errors:true but no affect.
11:59:34.469 INFO - Executing: [new session: {platform=ANY,
javascriptEnabled=true, browserName=phantomjs, version=,
ignore-ssl-errors=true}] at URL: /session)
11:59:34.485 INFO - Creating a new session for Capabilities [{platform=ANY,
javascriptEnabled=true, browserName=phantomjs, ignore-ssl-errors=true,
version=}]
11:59:34.516 INFO - executable: C:\Program Files\Selenium
Node\phantomjs\phantomjs.exe
11:59:34.516 INFO - port: 18110
11:59:34.516 INFO - arguments: [--webdriver=18110,
--webdriver-logfile=C:\Program Files\Selenium Node\phantomjsdriver.log]
11:59:34.516 INFO - environment: {}
PhantomJS is launching GhostDriver...
[INFO - 2013-06-19T01:59:36.466Z] GhostDriver - Main - running on port
18110
Cheers
Jules
On Wed, Jun 19, 2013 at 10:02 AM, Jeremy Johnson
notifications@github.comwrote:
ombre42 commentedon Jun 19, 2013
Here's what I have gathered:
The proper way to tell PhantomJS to accept all certs would be to use acceptSslCerts:true, but this capability is marked TODO.
When instantiating a local webdriver, Selenium2Library does not pass desired_capabilities to the constructor (or anything else for that matter). desired_capabilities is documented as such - *If you specify a value for remote you can also specify *...'desired_capabilities'...
@j1z0 Do you know why desired capabilities was never passed to the browser specific constructors and only to the remote webdriver?
So even if Selenium2Library were changed to pass the desired capabilities to the webdriver constructors, jbarnes007 would still be out of luck because acceptSslCerts is not implemented in PhantomJS
I see a few solutions here.
I was able to add an argument service_args to open_browser and pass that all the way down to _generic_make_browser which I changed to:
This allowed me to run a phantomJS this test against a site with a bad cert that otherwise would not load/pass:
ombre42 commentedon Jun 19, 2013
Answering my question to Jeremy...
The ability to pass in desired capabilities to the constructor is new for some browsers.
ie from 2.32, called capabilities
firefox from 2.26, called capabilities
opera from initial commit, called desired_capabilities
chrome from 2.8, called desired_capabilities
phantomjs from initial commit, called desired_capabilities
I do not understand why the commiter used a different argument name for the same thing when it was added to IE and Firefox.
The argument is not in the same position for the different webdrivers either :(
j1z0 commentedon Jun 20, 2013
Hey Kevin,
Regarding desired capabilities it IS passed into the BROWSER SPECIFIC constructors. But all the BROWSER SPECIFIC constructors just use the default GENERIC CONSTRUCTOR that only forwards desired capabilities to remote browsers.
Sorry for the caps just trying to make it clear, that each browser type has the option to create the browser however they want. This is by design and that way if PhantomJS uses non standard name of service_args then we can just modify the _make_phantomjs function to pass in desired capabilities as service_args and not have to add an additional service_args parameter for all other browsers that they won't need...
Adding one parameter is not a big deal, but if we end up having to add service_args for phantom_js, chrome_options for chrome, etc... etc... it can't get out of hand. So I designed it with the actory pattern to prevent that.
For the bigger question.
When I wrote it you couldn't pass desired capabilities on a local browser. But I think you make a good case that it needs to happen for things like acceptSslCerts now a days.
--edit--
based on your last comment, probably passing in desired_capabilities by keyword in the Generic constructor and overriding it for IE and Firefox... I think also the Chrome guys are talking about changing the name to Chrome_options or something like that (not sure if it will happen though).
Also regarding your suggesting for number 3. to manually construct the browser you would have to do that from code right? I mean there is no way to do it from RF Keywords correct? So what modifications are you suggesting? Because from code you can already put a manually constructed browser into the cache, given that nothing is really private in python. Just trying to understand what your looking for, cause I'm all for making things more flexible.
On Jun 20, 2013, at 12:40 AM, Kevin Ormbrek wrote:
ombre42 commentedon Jun 21, 2013
@jbarnes007 If you are interested in temporary workaround, I posted an example on the RF user group of how to open PhantomJS passing command line arguments. The example is for setting a proxy, but it should be obvious how to use it to ignore bad certs.
@j1z0 What you call constructors I call factory methods. To me, constructors are only new or init methods. What you did is a good design. It is challenging to wrap disparate constructors into one single method. On top of that, the signatures have changed in recent versions.
If PhantomJS fully supported the JsonWireProtocol, the only change we need to make is to have _generic_make_browser pass the DesiredCapabilities on to the browser-specific constructors. Perhaps that is all that should be done.
I think we could use reflection to find out if the init takes a desired_capabilities(or capabilities) argument and raise an error if the desired_capabilities passed to _generic_make_browser is not None and the argument is not present in the constructor (e.g. IE when Se < 2.32)
Chrome's constructor takes service_args, desired_capabilities, and chrome_options :(
As for a nice way to change Open Browser to support those I can't really think of anything. Perhaps an other_args argument that is a keyword argument dict, but that is pretty ugly. Of course so is having to write your own keyword to open the browser. What do you think?
Yes you can add a browser into the cache by accessing private methods. I was more referring to having an endorsed method that users can count on not changing (a PY API if you will) that also does the initial get() and logs session id.
j1z0 commentedon Jun 21, 2013
@ombre42
Yes good idea, making it public though will expose it to RF, I guess we can just add a docstring saying this is intending for extending S2L and not for being used through RF scripts..
ombre42 commentedon Jun 21, 2013
Yes. This is what I did for SudsLibrary. I also covered it in the library documentation.
Another route I never thought of was a separate API class with public methods, but that seems overly complicated.
bmannix commentedon Jul 10, 2013
Here is the related issue I opened with GhostDriver. https://github.com/detro/ghostdriver/issues/233
Selenium2Library won't be able to support this feature until:
detro commentedon Jul 10, 2013
Yep, as @bmannix, GhostDriver (the WebDriver inside PhantomJS) doesn't support the setting of that capabilty yet.
Unfortunately PhantomJS accepts that only via CLI parameter.
But there is a capability to provide an array of command line parameters: that way you can circumvent the problem for now.
See the issue that @bmannix referred above.
ombre42 commentedon Jan 3, 2014
This should be possible with Create Webdriver, new in 1.5. Try something like this:
If PhantomJS adds the capability to set ignore-ssl-errors via desired capabilities in the future, then Open Browser would be easier.