robotframework / SeleniumLibrary

Web testing library for Robot Framework
Apache License 2.0
1.39k stars 764 forks source link

requesting "state of art" documentation about desired_capabilities #580

Closed andreabisello closed 7 years ago

andreabisello commented 8 years ago

Hi

Can someone write a documentation about desired_capabilites ?

i'm losing myself inside documentation, example and code.

i'm not able to understand if :

  1. desired_capabilites can be used on local browser or only on remote browser
  2. desired_capabilites can be used with every browser
  3. HOW use desired_capabilites

googling i find some examples about python or java, but not examples in native robotframework style.

the nearest answer to my problem can be

http://stackoverflow.com/questions/31058663/change-browser-capabilities-through-robot-framework

where there are an example of settings desired capabilites, but i think this syntax is not robot native

${dc} Evaluate sys.modules['selenium.webdriver'].DesiredCapabilities.INTERNETEXPLORER sys, selenium.webdriver

desired capabilites lists is https://github.com/SeleniumHQ/selenium/wiki/DesiredCapabilities ?

THANKS for the awesome robot framework.

HelioGuilherme66 commented 8 years ago

I agree that documentation is scattered and in need of a good tutorial. The reason about mentions of remote webdriver for accepting desired capabilities, is historical. It started that way. I admit that Selenium2Library did not keep the same updating pace as the core library is being developed (and S2L is based in the Python port, which sometimes is a bit behind the Java core).

The solution you found is a low level workaround to get things done, and it is Robot Framework legit code. The Evaluate keyword evaluates Python code directly but needs to have the used modules referenced just like you would with the import statement. So, the code below creates a dictionary of current browser capabilities, then sets a new key and finally opens the browser (calls the create webdriver). This must be done in this order, capabilities can only be changed before calling webdriver.

${dc}   Evaluate    sys.modules['selenium.webdriver'].DesiredCapabilities.INTERNETEXPLORER  sys, selenium.webdriver
Set To Dictionary   ${dc}   ignoreProtectedModeSettings ${True}
Open Browser    www.google.com  ie  desired_capabilitie=${dc}

So we have this way to get things done, and because each browser have different "capabilities" or names, an all purpose solution is hard to create. One particular case is the PhantomJS browser that most of the times I must use the Create Webdriver keyword to pass some parameters.

aaltat commented 8 years ago

Sometimes it could be handy let the user create the driver as they please in the Python side and there could be Register Driver keyword/API in Selenium2Library to store the driver. This could be handy because creating driver is hard in Robot data, user needs are different and flexibility of selenium brings it own challenges.

andreabisello commented 8 years ago

thanks.

So maybe it should be useful to add some examples and some explanations here http://robotframework.org/Selenium2Library/doc/Selenium2Library.html#Open%20Browser , maybe on the description, writing something like

" there is not a robotic way to handle capabilites becase .... so you can ... like those examples .... using permission from here https://github.com/SeleniumHQ/selenium/wiki/DesiredCapabilities ... remember that not all the browser permits the same capabilites ... [ ... ] "

i'm a junior python developer and robot user and i don't have the required experience and knownledge to write good documentation and examples, but if i can help somehow, i'm here.

aaltat commented 8 years ago

Creating the driver is actually quite complex and perhaps it would be better to write a wiki page (or similar). The keyword documentation should be easy to understand and cover the basic needs.

Covering beyond the basic need is, perhaps, better covered in other medias where the format is more flexible and better suited for this need. Perhaps something similar as the Robot Framework Quick Start Guide, which can be also executed by pybot.

aaltat commented 7 years ago

This is actually duplicate of #529 and therefore closing