-
Notifications
You must be signed in to change notification settings - Fork 751
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Improve Create Webdriver keyword documentation #529
Comments
I didn't follow the user group discussion closely but there might also be some discussion/words in the conversation that would provide context for the code above as well as more information. |
Good point, here is the original discussion: https://groups.google.com/d/msg/robotframework-users/r3rxgSv1Cs0/rzzc1fmwEQAJ |
Another example. Same as above but for REMOTE usage of chrome webdriver with selenium server standalone: https://groups.google.com/forum/#!topic/robotframework-users/gPsiVaMo19A |
I'd like to see also an example (for all supported browsers) how to set Accept-Language HTTP header (see Setting language preferences in a browser). AFAIK Python/Firefox is: FirefoxProfile profile = new FirefoxProfile();
profile.setPreference("intl.accept_languages", "no,en-US,en");
WebDriver driver = new FirefoxDriver(profile); But this needs to be translated to Robot (for dummies). |
We should think about extending some of the introductory paragraphs to give details on using Create WebDriver as well as the parameters for Open Browser. |
Good point, the keyword documentation is coming quite long and putting that to separate chapter is a good idea. Also with the same context, thinking what to do with #532, could be useful. |
One more goody for all´y´all my robot-friends ;-) How To: Change the language of Firefox browserFind below pure Selenium (Python bindings) & Robot Framework syntax to start Firefox Webdriver browser with specified locale / language. Selenium Python bindings code (which you can try directly in Python interactive shell): from selenium import webdriver
firefox_profile = webdriver.FirefoxProfile()
firefox_profile.set_preference("intl.accept_languages", "ru")
browser = webdriver.Firefox(firefox_profile)
browser.get("http://www.youtube.com") This should serve you youtube with a Russian UI (navigation). Change Robot Framework (selenium2library) code: # keyword definition
*** Keywords ***
| Open URL in Firefox GERMAN |
| | [Arguments] | ${url}
| | [Documentation] | Starts a Firefox browser with specified locale.
| | ${profile}= | Evaluate | sys.modules['selenium.webdriver'].FirefoxProfile() | sys
| | Call Method | ${profile} | set_preference | intl.accept_languages | de
| | Create WebDriver | Firefox | firefox_profile=${profile}
| | Go To | ${url}
# keyword call
*** Test Cases ***
| Open Youtube with German UI
| | Open URL in Firefox GERMAN | http://www.youtube.com
Pass locale as argument: *** Keywords ***
| Open URL in Firefox with desired language |
| | [Arguments] | ${url} | ${locale}
| | [Documentation] | Starts a Firefox browser with specified locale.
| | ${profile}= | Evaluate | sys.modules['selenium.webdriver'].FirefoxProfile() | sys
| | Call Method | ${profile} | set_preference | intl.accept_languages | ${locale}
| | Create WebDriver | Firefox | firefox_profile=${profile}
| | Go To | ${url}
*** Test Cases ***
| Open Youtube with Russian UI
| | Open URL in Firefox with desired language | http://www.youtube.com | ru Other languesGerman: "de" For more look up in Firefox´s preferences / content / Languages Final notesNote that with above approach youtube.com will still serve you content appropriate for your country regardless of locale settings, e.g. in Germany I will see German content even if I start Firefox with Russian locale |
@Tset-Noitamotua Thank you for sharing. Looking at more examples makes me think the |
@ombre42 |
Hi all, thanks for the info, I still have some questions though: It seems to me that the solution is not directly applicable under Jython version of the Library (running Selenium2Library under maven plugin) - or to put it in another way: What's the Jython version equivalent of this solution, in particular the line that goes like: Thanks in advance |
Hi all. I think this would be useful. I'm unable to use the Chromedriver due to a virtualbox/Ubuntu graphics driver bug, which I can fix in Chrome by disabled hardware acceleration, but I need to find a way of replicating this within RFW. I'll update with how I get on. |
If you need help, could you show the Python code? In this way it could be easier to help you to solve the problem. |
Wasn't using Python, but using the Robot syntax. Applying the following allows me to load Chrome with hardware acceleration disabled: ${options}= Evaluate sys.modules['selenium.webdriver'].ChromeOptions() sys
Call Method ${options} add_argument --disable-gpu\=true
Create webdriver Chrome chrome_options=${options} |
Perhaps it would be good idea to write documentation to rst file and create a link to README.rst file and second link to keyword documentation. That way the doc would be in the version same control as the keyword documentation and the keyword documentation would not grow too big. The most difficult thing is to decice the name for the file: Would you be interested to make a pull request and gather documentation to a single file? |
Hah - I'll try and get some time and submit a PR with one of the above files if I get some time in the next couple of days |
I wouldn't be too worried about keyword docs growing too big. Having all docs in one place has its benefits. That said, it might be a good idea to have larger examples, especially when the example involves multiple keywords, outside the keyword docs. In that case I'd at least initially keep all such examples in one reST file. Different examples could be split into separate sections, table of contents added to the top, etc. If this file would then grow too large to maintain, the reST source code could be split and end result combined into a single document. At that point it would probably be a good idea to start using Sphinx and host docs at Read the Docs. In the beginning just having something like |
I'm not sure if this is a bug or a documentation issue so please comment and I'll open a new issue if needed. The same identifiers for browser that work with
This produces quite frustrating error: This, however works:
I would appreciate the same kind of table that is in the keyword documentation of |
@Tattoo it's by design and documented in the Create Webdriver keyword. It must match to objects defined in the selenium side. |
Ah, I see. Sorry I missed that Could that be similar table as with |
It is possible, but it would required some work to be done, nothing too complex though. Now the code is quite simple on that side: And if new browsers emerge or new ways to launch existing browsers, it does not require changes from S2L side. |
All the above does not mean that I am against the chance, but in the other hand I don't have a need to make the change either. If you want to change it, cloud you raise a separate issue about it and even better if there is a PR to support the issue. |
I now thinking that Create WebDriver should be deprecated and Open Browser should be enhanced instead. This is planned in the 4.0 release. Therefore I don't plan to put effort in Create WebDriver keyword and I am closing this issue. |
From user group, send by: Wagner Wladislaw
I think it's a good addition to the keyword documentation.
The text was updated successfully, but these errors were encountered: