Skip to content

Conversation

@HelioGuilherme66
Copy link
Member

Returns a dictionary with keys accessible as attributes of the current browser capabilities.

Includes examples with logging of Common Browsers capabilities.

This PR overrides PR #482 and fixes #980.

@HelioGuilherme66 HelioGuilherme66 force-pushed the get_browser_capabilities branch 2 times, most recently from 3b7b481 to 24baf59 Compare November 1, 2017 21:35
Copy link
Contributor

@aaltat aaltat left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The code side looks OK but there are few things which needs to be fixed before this can be merged.

% self.browser.session_id)

@keyword
def get_browser_capabilities(self):
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Write: Gets current browser capabilities as dictionary

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Done

def get_browser_capabilities(self):
"""Gets current browser capabilities from webdriver.
Returns a Dictionary with webdriver (browser) desired capabilities attributes.
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Instead of explaining how RF dictionary works, it might be better idea to link in RF user guide: http://robotframework.org/robotframework/latest/RobotFrameworkUserGuide.html#dictionary-variables and to the chapter which explains DotDic usage.

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I am keeping as it is. Better explicit than implicit. We don't have much examples on how to use SeleniumLibrary with dictionary attributes.

Returns a Dictionary with webdriver (browser) desired capabilities attributes.
You may also query keys providing a default value when those keys are nonexistent.
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Does the browser drivers, like Chrome driver, has documentation what they return. If there is, it would be better to link in those documents.

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

There is the Webdriver standard mentioned in doc (and Firefox is not following it completely, for platform and version).

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It would be better to link to the WebDriver documentation instead to trying to explain all in our documentation.

Note: Firefox/Geckodriver is returning different names for '*platform*' and '*version*'.
It returns: '*platformName*' and '*browserVersion*'.
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The example explains how RF dictionary works, which is best to leave to RF documentation. Perhaps providing few common attributes, like browserName would be enough.

New in SeleniumLibrary 3.0.
"""

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Write return DotDic (self.browser.desired_capabilities)

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Also remove not required new lines.

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Done

@@ -0,0 +1,16 @@
class AttrDict(dict):
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Should we rename this in same way as RF DotDic.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Although code is simple write few unit test might be good idea.

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This, I don't agree. I only added AttrDict because of RF 2.8.7 compatibility. It is a temporary workaround.
The original PR had unit tests, but they will not be necessary because it is temporary.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

There already is some temporary code, waiting for the minimum RF version to raise high enough and they also have unit tests. So having something as temporally and not writing test for it, is not valid reason. Also it would lift the burden from the acceptance test, that one does not have to verify that value is in the right key in the acceptance test level.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Couldn't this just wait until we drop RF 2.8.7 support? I don't think this can make it to 3.0 anyway.


Create Webdriver With Bad Keyword Argument Dictionary
[Documentation] Invalid arguments types
Run Keyword And Expect Error kwargs must be a dictionary.
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Having own test suite is better idea.

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Done

Run Keyword And Expect Error kwargs must be a dictionary.
... Create Webdriver Firefox kwargs={'spam': 'eggs'}

Get Browser Capabilities Using Dictionary
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Could you change the test that one test tests only a one thing. Also get rid of the stuff which is not anymore valid like the [Setup].

... Create Webdriver Firefox kwargs={'spam': 'eggs'}

Get Browser Capabilities Using Dictionary
[Documentation] Gets current browser capabilities from WebDriver
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

If the doc repeats the test name, then it's not useful and must be removed.

${capabilities}= Get Browser Capabilities
Log Capabilities = ${capabilities}
${browser}= Normalize Browser Name
Should Match ${capabilities['browserName']} ${browser}
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Change tests that it checks keys and does not care about the value. Because value changes between browser and perhaps Selenium version.

Test in the unit test level that correct value is in correct key.

Returns a dictionary with keys acessible as attributes of the current browser capabilities. Includes examples with logging of Common Browsers capabilities. Fixes unit tests when running on robotframework 2.8.7. Adds unit tests for DotDict. Moves acceptance tests to its own test suite.
 because next test suite is expecting an opened browser.
@HelioGuilherme66
Copy link
Member Author

I consider Done the changes to this PR.
Build is green again :)

@nkrishnanChrome
Copy link

nkrishnanChrome commented Feb 15, 2018

For this to be impelemented in SeleniumLibrary2.7 i had to make a small change to the existing code.
if you use browser you get attribute error. It makes sense to have current browser in session to scrape the data from the console log

return self._current_browser().get_log(log_type)

@aaltat
Copy link
Contributor

aaltat commented Apr 22, 2019

@HelioGuilherme66 would you be still interested to contribute this to the project? Because Robot Framework minimum version is raised to 3.0.4 in the SeleniumLibrary 4.0 release and therefore we could delete that dotdic implementation from this PR. Or can we close this PR?

@aaltat
Copy link
Contributor

aaltat commented May 21, 2019

Closing due inactivity.

@aaltat aaltat closed this May 21, 2019
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

4 participants