robotframework / seleniumlibrary Goto Github PK
View Code? Open in Web Editor NEWWeb testing library for Robot Framework
License: Apache License 2.0
Web testing library for Robot Framework
License: Apache License 2.0
I fixed this in my fork by changing
webdriver.Remote(desired_capabilities=desired_cap , command_executor=str(remote_url), browser_profile=profile)
to
webdriver.Remote(str(remote_url), capabilities_type)
in _browsermanagment.py
however it won't work with profiles or capabilities other that browser type, I don't know how to do it since I couldn't find selenium2 python bindings documentation that is up to date. Only useful thing I found was here http://seleniumhq.org/docs/04_webdriver_advanced.html#remotewebdriver, it provides basic working example.
I can't use select_frame to select an iframe because it select frame only.
-----code-------
My recently added changes to implement Selemiun 2's implicitly_wait functionality don't seem to have the behavior I expected. I should have written some test code BEFORE I wrote code to implement the functionality but I didn't. I am working on correcting that bad behavior by adding some tests which can be found under my branch selemium-implicit-wait.
The tests look to see whether or not an element is present after a button push results in that additional element after a delay. The test page I lifted directly from the test code of Selenium (thinking what better way to test then in a similar matter as Selenium itself). Here are a couple of example tests
*** Settings ***
Resource ../resource.txt
*** Test Cases ***
Implicit Wait 10 seconds For 4000 Element
Set Selenium Speed 0 seconds
Set Selenium Timeout 0 seconds
Set Selenium Implicit Wait 10 seconds
Go To Page "javascript/dynamic_timeout.html?timeout=4000"
Page Should Not Contain Element css=html body div#box0.redbox
Click Element adder
Page Should Contain Element css=html body div#box0.redbox
# ...
Implicit Wait 0 seconds For 4000 Element
Set Selenium Speed 0 seconds
Set Selenium Timeout 0 seconds
Set Selenium Implicit Wait 0 seconds
Go To Page "javascript/dynamic_timeout.html?timeout=4000"
Page Should Not Contain Element css=html body div#box0.redbox
Click Element adder
Page Should Not Contain Element css=html body div#box0.redbox
# ...
The former sets the implicit wait to 10 seconds and expects the red box (i.e. the delayed added element) which should appear after 4 seconds. The latter sets the implicit wait to zero seconds and should not expect to see the element as it doesn't appear immediately. Now these initial tests, which are failing, are just that preliminary. I am not sure whether they are just poorly written or wrong tests (is one of the test keywords or the initial set_implict_wait default playing with the timing), or whether my implicit_wait rb-s2library code is coded wrong, or whether something within robotframework design is conflicting with how to Selenium 2 library implements the implicit wait functionality, or whether something else or a combination of issues are causing the initial tests to fail?
But I wanted to push these initial tests onto my branch to make others aware of the issues I am seeing and show what steps I am taking to look into them. I welcome any collaborators!!!
It appears the 'Set Selenium Timeout' keyword does not actually set the timeout. The code as currently written
def set_selenium_timeout(self, seconds):
# . . .
old_timeout = self.get_selenium_timeout()
self._timeout_in_secs = robot.utils.timestr_to_secs(seconds)
return old_timeout
def set_selenium_implicit_wait(self, seconds):
# . . .
and the code as I suspect it should be
def set_selenium_timeout(self, seconds):
# . . .
old_timeout = self.get_selenium_timeout()
self._timeout_in_secs = robot.utils.timestr_to_secs(seconds)
for browser in self._cache.browsers:
browser.set_script_timeout(self._timeout_in_secs)
return old_timeout
def set_selenium_implicit_wait(self, seconds):
# . . .
Also it appears this feature is untested within the rf-s2l acceptance tests.
When using a Remote WebDriver, call keyword Capture Page Screenshot. Result:
FAIL AttributeError: 'WebDriver' object has no attribute 'save_screenshot'
The remote driver in the Selenium Python bindings defines a method called get_screenshot_as_file instead of save_screenshot, but they perform the same action and have the same signature.
A simple workaround for this:
on Line 27 of keywords/_screenshot.py,
replace:
self._current_browser().save_screenshot(path)
with:
if hasattr(self._current_browser(), 'get_screenshot_as_file'):
self._current_browser().get_screenshot_as_file(path)
else:
self._current_browser().save_screenshot(path)
robotframework-selenium2library-1.0.0 is supported by pip, while robotframework 2.6.3 is a dependency, but is not supported by pip
This is problematic
Selenium2Library is installed (on Windows) using pip or easy_install. But these tools do not work on computers behind a proxy. Installing manually falls from one missing component into the next missing component.
Please provide a Windows installer for Selenium2Library that includes installing all dependancies. I would need it for Windows XP and Windows 7.
Thanks and best regards
Gerhard
The app I'm currently testing contains a number of select controls that contain dynamic values. As the 'select from list' keyword does not allow for regular expressions, I need a new library keyword to allow selection bases on a regexp pattern. I've had a quick stab at this myself, and added the following code to my _selectelement.py. However, I don't know Python and I'm sure someone who does could do a much more elegant job.
import re
def select_from_list_regexp(self, locator, regexp):
select, options = self._get_select_list_options(locator)
option_labels = self._get_labels_for_options(options)
i = -1
option_index = None
found = False
for label in option_labels:
i+=1
if re.search(regexp, label):
option_index = i
self._info("Match for regexp '%s': label='%s'; index=%s" % (regexp, label, i))
found = True
break
if not found:
self._info("Failed to find a match for regular expression '%s' in list %s." % (regexp, locator))
self._select_option_from_single_select_list(select, options, option_index)
This code seems to work ok, but it doesn't allow for multiple items or for the selection of the nth match of an expression. Perhaps this could be implemented in the next release of the library?
Cheers,
Rob
The key word 'select frame' can't recoginze iframes which are dynamic genrerated by Ajax.
I tried selenium2 python binding it works fine.
so I checked source code (_browsermanagement.py) and made some changeοΌthenοΌ It worked.
I wonder the function of the two lines ( I can't find the realizition of _element_find.)
#element = self._element_find(locator, True, True, tag='frame')
#self._current_browser().switch_to_frame(element)
def select_frame(self, locator):
"""Sets frame identified by `locator` as current frame.
Key attributes for frames are `id` and `name.` See `introduction` for
details about locating elements.
"""
self._info("Selecting frame '%s'." % locator)
#element = self._element_find(locator, True, True, tag='frame')
#self._current_browser().switch_to_frame(element)
self._current_browser().switch_to_frame(locator)
Hi.
....
16:42:09.582 INFO Clicking link 'Continue to this website (not recommended).'.
16:42:10.113 FAIL TypeError: object of type 'NoneType' has no len()
....
Hi there,
I am using IE8 with latest lib and RF, I am trying to click an area with its id. The click doesn't fire any action. I noticed that when I use IE developer tools to locate the area with id, the coords number of that area seems to be wrong(I saw a blue rectangle in other places rather than surrounding the area). Is this the reason why the click is not working?
Thanks!
Adam
it seems that currently selenium2lib doesn't support testing via IE proxy. I have some tests works fine without proxy in IE, however, when I configured proxy, then I got following errors:
WebDriverException: Message: '\n\n<title>404 Not Found</title>\n\n
The requested URL /hub/session was not found on this server.
\n\nI am wondering whether any one has solutions for this already?
Thanks!
Adam
Try this script
Set Log Level TRACE
Open Browser http://fancybox.net/home ie
click element id=various5
Select Frame id=fancybox-frame
Close All Browsers
You will notice that iframe fancybox-frame has been opened, and can be located in IE Dev Tools, however, Select Frame keywords break with following error and trace info:
KEYWORD: Selenium2Library.Select Frame id=fancybox-frame
Documentation: Sets frame identified by locator
as current frame.
+KEYWORD: Selenium2Library.Capture Page Screenshot
Documentation: Takes a screenshot of the current page and embeds it into the log.
Start / End / Elapsed: 20111202 21:58:10.724 / 20111202 21:58:11.489 / 00:00:00.765
21:58:10.443 TRACE Arguments: [ u'id=fancybox-frame' ]
21:58:10.443 INFO Selecting frame 'id=fancybox-frame'.
21:58:10.443 DEBUG POST http://127.0.0.1:51969/session/393b64e2-054d-4c35-8ca7-78a2bf67c307/elements {"using": "id", "sessionId": "393b64e2-054d-4c35-8ca7-78a2bf67c307", "value": "fancybox-frame"}
21:58:10.708 DEBUG GET http://127.0.0.1:51969/session/393b64e2-054d-4c35-8ca7-78a2bf67c307/element/d9730baa-de31-4bd3-acc3-edc0ebb25eb1/name {"sessionId": "393b64e2-054d-4c35-8ca7-78a2bf67c307", "id": "d9730baa-de31-4bd3-acc3-edc0ebb25eb1"}
21:58:11.489 FAIL ValueError: Element locator 'id=fancybox-frame' did not match any elements.
21:58:11.489 DEBUG Traceback (most recent call last):
File "", line 2, in select_frame
File "C:\Python27\lib\site-packages\Selenium2Library\keywords\keywordgroup.py", line 12, in _run_on_failure_decorator
return method(_args, *_kwargs)
File "C:\Python27\lib\site-packages\Selenium2Library\keywords_browsermanagement.py", line 157, in select_frame
element = self._element_find(locator, True, True, tag='frame')
File "C:\Python27\lib\site-packages\Selenium2Library\keywords_element.py", line 502, in _element_find
raise ValueError("Element locator '" + locator + "' did not match any elements.")
Hi,
after updating to Firefox 8 I had the problem that my tests were not executed. The browser windows is getting opened but after that nothing happens. After I long search I find out that selenium2Lib uses default Firefox Profile which is in the installation path of the library. For some reason this can not be loaded.
I have fixed this for me locally in this way:
def init(self,profile_directory=None):
Here are two changes possible depending of this what you want to do:
2.1 if you want to use your own specified profile the method will looks like this:
self.default_preferences = copy.deepcopy(FirefoxProfile.DEFAULT_PREFERENCES)
self.profile_dir = '<PATH_TO_YOUR_FF_PROFILE>'
self._read_existing_userjs()
self.extensionsDir = os.path.join(self.profile_dir, "extensions")
self.userPrefs = os.path.join(self.profile_dir, "user.js")
2.2 If you want that every time anonymous profile is created in the temp folder and used that it will look like this:
self.default_preferences = copy.deepcopy(FirefoxProfile.DEFAULT_PREFERENCES)
self.profile_dir = profile_directory
if self.profile_dir is None:
self.profile_dir = self._create_tempfolder()
else:
newprof = os.path.join(tempfile.mkdtemp(),
"webdriver-py-profilecopy")
shutil.copytree(self.profile_dir, newprof)
self.profile_dir = newprof
self._read_existing_userjs()
self.extensionsDir = os.path.join(self.profile_dir, "extensions")
self.userPrefs = os.path.join(self.profile_dir, "user.js")
Will it be possible to fix this in future releases, so that no code changes are needed after update?
Thanks
#Firefox 10.0.2
cd test && run_tests.py python ff
Documentation:
Verifies the value in text field identified by `locator` is exactly `expected`.
Start / End / Elapsed: 20120625 15:14:57.896 / 20120625 15:14:57.915 / 00:00:00.019
15:14:57.898 DEBUG GET http://127.0.0.1:58434/hub/session/cb4018b6-160c-6d45-bb09-433c11f8f179/url {"sessionId": "cb4018b6-160c-6d45-bb09-433c11f8f179"}
15:14:57.903 DEBUG POST http://127.0.0.1:58434/hub/session/cb4018b6-160c-6d45-bb09-433c11f8f179/elements {"using": "xpath", "sessionId": "cb4018b6-160c-6d45-bb09-433c11f8f179", "value": "//input[@type='text' and (@id='el_for_mouseout' or @name='el_for_mouseout' or @value='el_for_mouseout' or @src='el_for_mouseout' or @src='http://localhost:7000/html/mouse/el_for_mouseout')]"}
15:14:57.909 DEBUG GET http://127.0.0.1:58434/hub/session/cb4018b6-160c-6d45-bb09-433c11f8f179/element/{556a6780-d460-1948-aabe-9617e66d7706}/attribute/value {"sessionId": "cb4018b6-160c-6d45-bb09-433c11f8f179", "name": "value", "id": "{556a6780-d460-1948-aabe-9617e66d7706}"}
15:14:57.915 FAIL Value of text field 'el_for_mouseout' should have been 'mouseout el_for_mouseout' but was ''
15:14:57.915 DEBUG Traceback (most recent call last):
File "<string>", line 2, in textfield_value_should_be
File "/Users/jollychang/Works/robotframework-selenium2library/src/Selenium2Library/keywords/keywordgroup.py", line 12, in _run_on_failure_decorator
return method(*args, **kwargs)
File "/Users/jollychang/Works/robotframework-selenium2library/src/Selenium2Library/keywords/_formelement.py", line 253, in textfield_value_should_be
raise AssertionError(message)
KEYWORD: Selenium2Library.Location Should Be ${ROOT}/${relative url} Expand All
Documentation:
Verifies that current URL is exactly `url`.
Start / End / Elapsed: 20120625 15:15:50.036 / 20120625 15:15:50.067 / 00:00:00.031
15:15:50.037 DEBUG GET http://127.0.0.1:58434/hub/session/cb4018b6-160c-6d45-bb09-433c11f8f179/url {"sessionId": "cb4018b6-160c-6d45-bb09-433c11f8f179"}
15:15:50.067 FAIL Location should have been 'http://localhost:7000/html/forms/submit.html' but was 'http://localhost:7000/html/forms/login.html'
15:15:50.067 DEBUG Traceback (most recent call last):
File "<string>", line 2, in location_should_be
File "/Users/jollychang/Works/robotframework-selenium2library/src/Selenium2Library/keywords/keywordgroup.py", line 12, in _run_on_failure_decorator
return method(*args, **kwargs)
File "/Users/jollychang/Works/robotframework-selenium2library/src/Selenium2Library/keywords/_browsermanagement.py", line 231, in location_should_be
% (url, actual))
create a travis-ci project is good idea?
My tests fail during teardown with following errors, it seems screenshot capture fails.
13:27:59.164 TRACE Arguments: [ ]
13:27:59.174 DEBUG GET http://127.0.0.1:1363/hub/session/70000fba-176c-48cb-8f60-4adbfe323390/screenshot {"sessionId": "70000fba-176c-48cb-8f60-4adbfe323390"}
13:28:00.165 FAIL URLError: <urlopen error [Errno 10061] No connection could be made because the target machine actively refused it>
13:28:00.165 DEBUG Traceback (most recent call last): File "", line 2, in capture_page_screenshot File "C:\Python27\lib\site-packages\robotframework_selenium2library-1.0.0-py2.7.egg\Selenium2Library\keywords\keywordgroup.py", line 12, in _run_on_failure_decorator return method(_args, *_kwargs) File "C:\Python27\lib\site-packages\robotframework_selenium2library-1.0.0-py2.7.egg\Selenium2Library\keywords_screenshot.py", line 27, in capture_page_screenshot self._current_browser().save_screenshot(path) File "C:\Python27\lib\site-packages\selenium-2.21.3-py2.7.egg\selenium\webdriver\firefox\webdriver.py", line 81, in save_screenshot png = RemoteWebDriver.execute(self, Command.SCREENSHOT)['value'] File "C:\Python27\lib\site-packages\robotframework_selenium2library-1.0.0-py2.7.egg\Selenium2Library\webdrivermonkeypatches.py", line 11, in execute result = self._base_execute(driver_command, params) File "C:\Python27\lib\site-packages\selenium-2.21.3-py2.7.egg\selenium\webdriver\remote\webdriver.py", line 151, in execute response = self.command_executor.execute(driver_command, params) File "C:\Python27\lib\site-packages\selenium-2.21.3-py2.7.egg\selenium\webdriver\remote\remote_connection.py", line 283, in execute return self._request(url, method=command_info[0], data=data) File "C:\Python27\lib\site-packages\selenium-2.21.3-py2.7.egg\selenium\webdriver\remote\remote_connection.py", line 324, in _request response = opener.open(request) File "C:\Python27\lib\urllib2.py", line 391, in open response = self._open(req, data) File "C:\Python27\lib\urllib2.py", line 409, in _open '_open', req) File "C:\Python27\lib\urllib2.py", line 369, in _call_chain result = func(_args) File "C:\Python27\lib\urllib2.py", line 1173, in http_open return self.do_open(httplib.HTTPConnection, req) File "C:\Python27\lib\urllib2.py", line 1148, in do_open raise URLError(err)
13:28:00.175 TRACE Return: None
13:27:58.223 TRACE Arguments: [ ]
13:27:58.223 DEBUG Closing browser with session id 70000fba-176c-48cb-8f60-4adbfe323390
13:27:58.223 DEBUG DELETE http://127.0.0.1:1363/hub/session/70000fba-176c-48cb-8f60-4adbfe323390 {"sessionId": "70000fba-176c-48cb-8f60-4adbfe323390"}
13:28:00.175 WARN Keyword 'Capture Page Screenshot' could not be run on failure: URLError: <urlopen error [Errno 10061] No connection could be made because the target machine actively refused it>
13:28:00.185 FAIL URLError: <urlopen error [Errno 10061] No connection could be made because the target machine actively refused it>
13:28:00.185 DEBUG Traceback (most recent call last): File "", line 2, in close_browser File "C:\Python27\lib\site-packages\robotframework_selenium2library-1.0.0-py2.7.egg\Selenium2Library\keywords\keywordgroup.py", line 12, in _run_on_failure_decorator return method(_args, *_kwargs) File "C:\Python27\lib\site-packages\robotframework_selenium2library-1.0.0-py2.7.egg\Selenium2Library\keywords_browsermanagement.py", line 50, in close_browser self._cache.close() File "C:\Python27\lib\site-packages\robotframework_selenium2library-1.0.0-py2.7.egg\Selenium2Library\utils\browsercache.py", line 23, in close browser.quit() File "C:\Python27\lib\site-packages\selenium-2.21.3-py2.7.egg\selenium\webdriver\firefox\webdriver.py", line 61, in quit RemoteWebDriver.quit(self) File "C:\Python27\lib\site-packages\selenium-2.21.3-py2.7.egg\selenium\webdriver\remote\webdriver.py", line 443, in quit self.execute(Command.QUIT) File "C:\Python27\lib\site-packages\robotframework_selenium2library-1.0.0-py2.7.egg\Selenium2Library\webdrivermonkeypatches.py", line 11, in execute result = self._base_execute(driver_command, params) File "C:\Python27\lib\site-packages\selenium-2.21.3-py2.7.egg\selenium\webdriver\remote\webdriver.py", line 151, in execute response = self.command_executor.execute(driver_command, params) File "C:\Python27\lib\site-packages\selenium-2.21.3-py2.7.egg\selenium\webdriver\remote\remote_connection.py", line 283, in execute return self._request(url, method=command_info[0], data=data) File "C:\Python27\lib\site-packages\selenium-2.21.3-py2.7.egg\selenium\webdriver\remote\remote_connection.py", line 324, in _request response = opener.open(request) File "C:\Python27\lib\urllib2.py", line 391, in open response = self._open(req, data) File "C:\Python27\lib\urllib2.py", line 409, in _open '_open', req) File "C:\Python27\lib\urllib2.py", line 369, in _call_chain result = func(_args) File "C:\Python27\lib\urllib2.py", line 1173, in http_open return self.do_open(httplib.HTTPConnection, req) File "C:\Python27\lib\urllib2.py", line 1148, in do_open raise URLError(err)
13:28:00.195 TRACE Return: None
We execute scripts through a corporate network. How do we handle proxy authentication.
Currently when we try to open a browser in FF, ride throws an error
WebDriverException: Message: '\n<TITLE>Access Denied</TITLE>\n\n\n\n
\n\n
\n\n\n\n\n\n\n\n\n'\n
\n\nAccess Denied (authentication_failed)\n
\n
\n\n\n\nYour credentials could not be authenticated: "Credentials are missing.". You will not be permitted access until your credentials can be verified.\n\n \n\nThis is typically caused by an incorrect username and/or password, but could also be caused by network problems.\n\n \n\n
\nFor assistance, contact your network support team.\n\n
When I try to use a simple test, I found that Get Windows Names / Titles / Identifies all breaks on IE8 / Win7, while FF works fine. The error is "TypeError: object of type 'WebElement' has no len()". Can someone help to look into this?
Select Window already fail with same error messages, I suspect the root cause is the same.
If you try to install robotframework-selenium2library via buildout it fails on the line
import metadata
due to a weird catch-22 situation. src/SeleniumLibrary/metadata imports in utils which eventually tries to import robot.utils which is part of the robotframework package. buildout is not aware of, at this point and may not need to be aware of, the robotframework egg. I recommend keeping a clean self-enclosed setup.py without a separate metadata.py file.
By default, the webdriver binaries are expected to be in the system path and the browser binaries in their default locations.
But this is not always possible. I need the flexibility to specify the path to the webdriver binaries and browser binaries. I currently do this for my selenium2 tests. I am trying to migrate them to rf-selenium2library and unable to run the tests.
I see couple of ways to do this:
. modify rf-selenium2library itself in place (I can do it, but don't favour doing it unless the authors are ready to accept it as a fix).
. extend rf-selenium2library and over ride the open_browser keyword (being new to RF - not sure how to do this - can you help please).
Are there any other ways to have the framework accept webdriver and browser binary paths?
Hi,
I have python installed at following location :
C:\apps\qsi_robot\python-2.7.2
I am using Custom batch file to run robot test cases and my python class path is set to following location:
C:\apps\qsi_harness\robot_libs
to import all robot libraries.
Is there a way that i can install selenium2 library in C:\apps\qsi_harness\robot_libs folder instead of
C:\apps\qsi_robot\python-2.7.2\Lib\site-packages
Mirroring an issue request from SeleniumLibrary for RF. There may be more requests of this nature in the future. And WebDriver may have some native solution in the future or not, so thus implementation may differ from SeleniumLibrary's request.
References:
RF user group request:
http://groups.google.com/group/robotframework-users/browse_thread/thread/4ad246ac0742ba3b
SeleniumLibrary issue 129
http://code.google.com/p/robotframework-seleniumlibrary/issues/detail?id=129
Selenium / WebDriver issue 95
http://code.google.com/p/selenium/issues/detail?id=95
You can captrue alert which is triggered by some event,bu you can't get it when triggered by "Execute Javascript"
the RF scripts is as follow:
*** Settings ***
Library Selenium2Library
*** Test Cases ***
alerttest
open browser http://localhost:7272 ie
click button button
Alert Should Be Present Hello!
AlertTriggeredbyJavascript
sleep 1s
execute javascript window.f()
Alert Should Be Present Hello!
and the second test case failed!
+KEYWORD: BuiltIn.Sleep 1s
Documentation: Pauses the test executed for the given time.
Start / End / Elapsed: 20120222 10:21:50.109 / 20120222 10:21:51.109 / 00:00:01.000
+KEYWORD: Selenium2Library.Execute Javascript window.f()
Documentation: Executes the given JavaScript code.
Start / End / Elapsed: 20120222 10:21:51.109 / 20120222 10:21:53.375 / 00:00:02.266
-+
KEYWORD: Selenium2Library.Alert Should Be Present Hello!
Documentation: Verifies an alert is present and dismisses it.
+KEYWORD: Selenium2Library.Capture Page Screenshot
Documentation: Takes a screenshot of the current page and embeds it into the log.
Start / End / Elapsed: 20120222 10:21:53.390 / 20120222 10:21:54.281 / 00:00:00.891
+KEYWORD: Selenium2Library.Capture Page Screenshot
Documentation: Takes a screenshot of the current page and embeds it into the log.
Start / End / Elapsed: 20120222 10:21:54.281 / 20120222 10:21:55.046 / 00:00:00.765
10:21:55.046 INFO
10:21:55.046 FAIL There were no alerts
IS there any difference between the tow way?
Here is the HTML under testing :
[input type="submit" name="button" id="button" value="ζδΊ€" onclick="f()" /]
[script type="text/javascript"]
function f()
{
alert("Hello!")
}
</script>
[/html]
Sometimes the underlying call to Selenium methods such as find_elements_by_xpath return a dict with value=None. This None value is propagated all the way up to _element._element_find, where len() is used to see how many elements were found. This will cause Wait Until Page Contains Element to fail immediately, since you can't use len on None.
Unfortunately I don't have a simple test/page to reproduce, but here's a log from executing Selenium2Library.Wait Until Page Contains Element id=delivery_date_select, 1m
08:31:43.590 DEBUG POST http://127.0.0.1:50341/session/a61ed99c-c9ed-4e49-9045-8b3c7724eeac/elements {"using": "id", "sessionId": "a61ed99c-c9ed-4e49-9045-8b3c7724eeac", "value": "delivery_date_select"}
08:31:44.160 DEBUG POST http://127.0.0.1:50341/session/a61ed99c-c9ed-4e49-9045-8b3c7724eeac/elements {"using": "id", "sessionId": "a61ed99c-c9ed-4e49-9045-8b3c7724eeac", "value": "delivery_date_select"}
08:31:44.573 FAIL TypeError: object of type 'NoneType' has no len()
08:31:44.574 DEBUG Traceback (most recent call last):
File "", line 2, in wait_until_page_contains_element
File "C:\apps\Python27\lib\site-packages\Selenium2Library\keywords\keywordgroup.py", line 12, in _run_on_failure_decorator
return method(_args, *_kwargs)
File "C:\apps\Python27\lib\site-packages\Selenium2Library\keywords_waiting.py", line 63, in wait_until_page_contains_element
self._wait_until(timeout, error, self._is_element_present, locator)
File "C:\apps\Python27\lib\site-packages\Selenium2Library\keywords_waiting.py", line 71, in _wait_until
while not function(*args):
File "C:\apps\Python27\lib\site-packages\Selenium2Library\keywords_element.py", line 593, in _is_element_present
return (self._element_find(locator, True, False, tag=tag) != None)
File "C:\apps\Python27\lib\site-packages\Selenium2Library\keywords_element.py", line 515, in _element_find
if len(elements) == 0: return None
Environment Info:
Question1_____
Do we need to start selenium server to use Selenium2Library in RIDE pls?
Trial Steps_____
20111228 16:07:26.315 ERROR Invalid syntax in file 'd:\ride\wu3\suites\Test1\Array.tsv' in table 'Setting': Importing test library 'Selenium2Library' failed: ImportError: No module named api
PYTHONPATH: ['C:\Python26\Lib\site-packages\Selenium2Library\lib\decorator-3.3.2', 'C:\Python26\Lib\site-packages\Selenium2Library\lib\selenium-2.8.1\py', 'C:\Python26\Lib\site-packages\Selenium2Library\lib\decorator-3.3.2', 'C:\Python26\Lib\site-packages\Selenium2Library\lib\selenium-2.8.1\py', 'C:\Python26\Lib\site-packages', 'C:\Python26\Lib\site-packages\robot\libraries', 'C:\jython2.5.1\Lib', 'classpath', 'pyclasspath/', 'C:\jython2.5.1\Lib\site-packages', 'D:\RIDE\wu3\lib', '.']
CLASSPATH: C:\jython2.5.1\jython.jar;C:\Python26\Lib;
Traceback (most recent call last):
File "C:\Python26\Lib\site-packages\robot\utils\importing.py", line 94, in import
import(name)
File "C:\Python26\Lib\site-packages\Selenium2Library__init_.py", line 8, in
from keywords import *
File "C:\Python26\Lib\site-packages\Selenium2Library\keywords__init__.py", line 1, in
from _logging import _LoggingKeywords
File "C:\Python26\Lib\site-packages\Selenium2Library\keywords_logging.py", line 4, in
from robot.api import logger
Import Selenium2Library module failed.
Please make sure you have Selenium2Library installed.
There is no rf-s2l keyword to call WebDriver's execute_async_script or exercise this asynchronous functionality. Note there is currently browser keywords for setting the selenium timeout which as far as I can see is the timeout only for asynchronous JavaScript calls.
The biggest problem this causes is that, for example, pip install Selenium2Library
does not work.
Adding the library into PyPI is easy. If you only want to submit the package metadata, all you need to do is running python setup.py register
.
For more information see:
http://pypi.python.org
http://wiki.python.org/moin/CheeseShopTutorial
Using windows, Python 2.7 and PIP, I have tried to install robotframework-selenium2library. However the pop up window when install PIP is too quick to read and it does not seem to install correctly.
Under the PIP/build folder I see the dependence I have downloaded
'decorator >= 3.3.2',
'selenium >= 2.8.1',
'robotframework >= 2.7.1',
'docutils >= 0.7'
When I run "pip install upgrade robotframework-selenium2library" the screen is too fast to see if it was successful. However as the folder is not created I assume it was not successful. The same for "selenium2library".
So, how can I keep the window open to see the issue?
And am I doing something wrong?
In particular, performance timings of content/file downloads, uploads, etc. along with viewing HTTP headers sent/received in browser.
Selenium RC had a captureNetworkTraffic option on startup of browser session to enable such functionality, though the user of course had to manually parse the desired data (or look for third party Selenium tools that did that).
WebDriver unfortunately doesn't natively support this, so just opening up a tracking issue for discussion and consideration of adding such functionality perhaps with third party tools.
See following for references:
Matching SeleniumLibrary issue 206
http://code.google.com/p/robotframework-seleniumlibrary/issues/detail?id=206
Request for such functionality at RF user group
http://groups.google.com/group/robotframework-users/browse_thread/thread/c44178c9edb4febe
Third party solutions to desired feature:
http://deanhume.com/Home/BlogPost/measuring-web-page-performance-with-selenium-2-and-the-web-timings-api/56
http://www.theautomatedtester.co.uk/blog/2010/selenium-webtimings-api.html
http://sevenseconds.wordpress.com/2011/06/28/velocity-conference-2011-workshop-on-automated-web-performance-testing/
http://www.supermind.org/blog/968/howto-collect-webdriver-http-request-and-response-headers
Hi there,
I have downloaded the latest lib, and trying in my system. I have trouble click an area, so I am trying to focus on the area first and then press an ENTER key. I am using PRESS KEY | myid | \13. However, I got following error: valueError: ("Key value '%s' is invalid.", u'13')
Thanks!
Adam
There was a bug against SeleniumLibrary 2.8 which is also present in robotframework-selenium2library
I'm wondering if you could incorporate the fix here as it causes Close All Browsers to fail for Suite Teardown.
The problem is here: http://code.google.com/p/robotframework-seleniumlibrary/issues/detail?id=220#c3
From what I read the same change could be applied to keywords/_browsermanagement.py's open_browser function.
From SeleniumLibrary's _browser.py:
try:
self._selenium.open(url, ignoreResponseCode=True)
self._debug('Opened browser with Selenium session id %s'
% self._selenium.sessionId)
except:
self._cache.register(self._selenium, alias)
raise RuntimeError("Open browser failed")
return self._cache.register(self._selenium, alias)
From Selenium2Library (which also needs to catch browser creation failures and register regardless):
browser = self._make_browser(browser_name,desired_capabilities,ff_profile_dir,remote_url)
browser.get(url)
self._debug('Opened browser with session id %s'
% browser.session_id)
return self._cache.register(browser, alias)
I haven't been following this project lately but recall that (initially at least) not all the keywords from SeleniumLibrary are supported.
It just occurred to me that we can better provide support for them now, and it's worth consideration for users to migrate over from SeleniumLibrary to Selenium2Library w/o having to make considerable changes to their tests, at least initially (for migration).
This issue is for the Call Selenium API keyword to be supported in this library as well as any other applicable unsupported SeleniumLibrary keywords.
Here's some options for supporting them:
Using the new server-side WebDriverBackedSelenium feature that should supposedly be available to Python.
http://seleniumhq.wordpress.com/2012/02/08/announcing-selenium-2-19-the-prancing-unicorn-release/
Another alternative option if that doesn't work out too well is to emulate/implement WebDriverBackedSelenium ourselves to replicate the needed functionality. I did some work on that for PHP already, before the server-side WebDriverBackedSelenium was made available. It could be adapted here for Python. And with this approach call to SeleniumLibrary keyword that's not available in Selenium2Library would go to these new emulated keyword methods, and Call Selenium API keyword could internally call these as well.
https://github.com/daluu/php-webdriver-bindings/blob/master/phpwebdriver/WebDriverBackedSelenium.php
And also regarding Call Selenium API keyword, if a native WebDriver approach (or Selenium2Library keyword) is available, then the keyword should call that, else fall back to using WebDriverBackedSelenium approach.
Just a placeholder for tracking and discussion. If I get to it, may have pull request for this as well (if I add RemoteWebDriver functionality to this library).
While not all the SeleniumLibrary import stuff and certain keywords relating to stop/start server may be relevant to Selenium 2, however some do apply.
For example server_host and server_port do apply when considering RemoteWebDriver and Selenium Grid2 deployment, and it also applies if we wanted to better support backward compatibility with SeleniumLibrary (less work to modify import statement in tests).
And jar_path for import along with keywords Start Selenium Server and Stop Selenium Server can apply for RemoteWebDriver case (maybe also Grid2, but not sure). For example: start up Selenium 2 server in standalone mode for use with RemoteWebDriver. Stop the server as needed (via WebDriver.close() on final/main browser window, or close all windows if more than one open to stop the server).
FYI, the Selenium 2 server is started in standalone mode (or RemoteWebDriver) as follows:
java -jar selenium-server-standalone-{VERSION}.jar
which uses default host and port of localhost, 4444.
To not break compatibility, these reinstated library import arguments would also be optional, in case user is not using RemoteWebDriver. For RF users who prefer backward compatibility in their tests that used to use SeleniumLibrary, they can run tests using this library via RemoteWebDriver + desired browser option rather than the native browser driver option. That way, not need to modify import statement. And they can switch back and forth between SeleniumLibrary and this library using same tests (in ideal world anyways). They would just need to manually start the server when using RemoteWebDriver is all, unless they use start/stop server keywords.
Guys,
I have a requirement to automate Dragging one element from source and dropping it into a target element. I see that drag and drop is not supported in selenium2library. Any alternatives? I am thinking of copying the same from Selenium1.
-Mamatha
Above is the html for a "Checkbox", the checkbox is covered by the label, and the checkbox is invisible.
The user can click the label to select the checkbox, but the automation cannot. It throws below error
"ElementNotVisibleException: Message: u'Element is not currently visible and so may not be interacted with'".
Seems Selenium2Library doesn't support the invisible element? How to solve this problem?
I have installed Selenium2 library with Robot framework and Ride and have configured corresponding Path variables.
I wrote a simple test to open a browser. However on Run i get the foll error. Kindly clarify
[ ERROR ] Error in file 'D:\py 2.7\Scripts\testRide\testride1.txt' in table 'Settings': Importing test library 'D:/py 2.7/Lib/site-packages/Selenium2Library' failed: ImportError: No module named decorator
PYTHONPATH: ['D:\py 2.7\Lib\site-packages\robot\libraries', 'D:\py 2.7\Lib', 'D:\py 2.7\Scripts', 'D:\py 2.7\Lib\site-packages', 'D:\py 2.7\Lib\site-packages\Selenium2Library', 'D:\py 2.7\Lib\site-packages\robotide', 'D:\py 2.7\Lib\site-packages\wx-2.8-msw-unicode', 'C:\WINNT\system32\python27.zip', 'D:\py 2.7\DLLs', 'D:\py 2.7\lib\plat-win', 'D:\py 2.7\lib\lib-tk', 'D:\py 2.7', 'D:\py 2.7\Lib\site-packages\robot', '.']
Traceback (most recent call last):
File "D:\py 2.7\Lib\site-packages\robot\utils\importing.py", line 84, in non_dotted_import
module = import_module_by_path(name)
File "D:\py 2.7\Lib\site-packages\robot\utils\importing.py", line 38, in import_module_by_path
module = import(modname)
File "D:\py 2.7\Lib\site-packages\Selenium2Library__init.py", line 2, in
from keywords import *
File "D:\py 2.7\Lib\site-packages\Selenium2Library\keywords__init_.py", line 1, in
from _logging import _LoggingKeywords
File "D:\py 2.7\Lib\site-packages\Selenium2Library\keywords_logging.py", line 5, in
from keywordgroup import KeywordGroup
File "D:\py 2.7\Lib\site-packages\Selenium2Library\keywords\keywordgroup.py", line 4, in
from decorator import decorator
for version 0.5.2, it works well. But I updated it to 1.0.0, it doesn't work.
I use the script following:
Wait until keyword succeeds 1min 5sec Select window windowname
Copying over request from SeleniumLibrary:
http://code.google.com/p/robotframework-seleniumlibrary/issues/detail?id=209
Any one has tried this?
Thanks!
Adam
The scenario is like this: when I jump a new page by Press Key //13, it will be handy to have "Wait Until Page Loaded" keyword.
quell code:
*** Variables *** ${userFieldLocator} xpath=//*[@id="username"] ... *** Test Cases *** ExampleTestCase wait until page contains element ${userFieldLocator} ...
error:
ValueError: Element locator 'xpath=//*[@id="username"]' did not match any elements.
Element '${userFieldLocator}' is located in iframe
This simple example works with 'SeleniumLibrary'
Jeremy,
I have seen examples of defining functions in python and the functions are called directly from a test in Robot. What I want is to follow the page object design concept where a page for example, home page is more like a class and the services offered by this page ex., login is a method within that class. In typical programming I would have a main that would instantiate an object of this class and access the services/methods within the class. Unable to relate on how I would integrate this with Robot framework. I could have these classes within a package and import them using the "ADD Library", But how would I instantiate the objects of classes. I figure I could have a function that incorporates instantiating the objects and then associate that with the test in robot framework. Am I on the right path ? or is there a more efficient way to do this ?
Appreciate your help and sorry if this too basic a question. I did look up some blogs before posting the question here.
-Mamatha
I have some once working tests that started to become very flaky and inconsistent, failing in different ways when repeated run. I have been making several changes including changes to robotframework_selenium2library/setup.py, removing static decorator and selenium libraries preferring to let buildout grab both the latest and pinned versions, adding selenium 2 implicitly_wait functionality, upgrading Firefox on Ubuntu 11.04 from the Ubuntu 11.04 bundled 4.0 up to Mozilla Team 9.0.beta back down to Mozilla Team 8.0. So any number of things could have caused my flakiness.
Searching I came across Selenium Issue# 2927 which has some similar characteristics. I was expriencing inconsistant results from run to run but no issues with sockets. I removed the Firefox profile, as shown here in this diff
diff --git a/src/Selenium2Library/keywords/_browsermanagement.py b/src/Selenium2
index 6101fe4..774eef4 100644
--- a/src/Selenium2Library/keywords/_browsermanagement.py
+++ b/src/Selenium2Library/keywords/_browsermanagement.py
@@ -7,8 +7,8 @@ from Selenium2Library.utils import BrowserCache
from Selenium2Library.locators import WindowManager
from keywordgroup import KeywordGroup
-ROOT_DIR = os.path.abspath(os.path.join(os.path.dirname(__file__), ".."))
-FIREFOX_PROFILE_DIR = os.path.join(ROOT_DIR, 'resources', 'firefoxprofile')
+#ROOT_DIR = os.path.abspath(os.path.join(os.path.dirname(__file__), ".."))
+#FIREFOX_PROFILE_DIR = os.path.join(ROOT_DIR, 'resources', 'firefoxprofile')
BROWSER_NAMES = {'ff': '*firefox',
'firefox': '*firefox',
'ie': '*iexplore',
@@ -353,7 +353,8 @@ class _BrowserManagementKeywords(KeywordGroup):
browser_token = self._get_browser_token(browser_name)
browser = None
if browser_token == '*firefox':
- browser = webdriver.Firefox(webdriver.FirefoxProfile(FIREFOX_PROFIL
+ #browser = webdriver.Firefox(webdriver.FirefoxProfile(FIREFOX_PROFI
+ browser = webdriver.Firefox()
elif browser_token == '*googlechrome':
browser = webdriver.Chrome()
elif browser_token == '*iexplore':
and experienced some improvement. But I noticed still some flakiness and by accident I also noticed my mouse over elements that seemed to be unable to locate. If I move my mouse away from the test browser running the tests are much more consistent.
So I am not sure of the root cause of the issue whether mouse position over test browser or Firefox profile or some issue altogether different but I wanted to record what I am seeing in case others are experiencing similar issues.
Ubuntu 11.04
Firefox 8.0, 9.0beta
Selenium 2.13.1, 2.14.0
robotframework-selenium2library 0.5.3 with modifications
robotframework 2.6.2
Install Chrome webdriver from http://code.google.com/p/chromium/downloads/list
Use the Capture Page Screenshot keyword
Error in RF Log:
KEYWORD: Selenium2Library.Capture Page Screenshot
Documentation: Takes a screenshot of the current page and embeds it into the log.
Start / End / Elapsed: 20111103 05:01:45.742 / 20111103 05:01:45.760 / 00:00:00.018
05:01:45.760 FAIL AttributeError: 'WebDriver' object has no attribute '_execute'
05:01:45.760 WARN Keyword 'Capture Page Screenshot' could not be run on failure: AttributeError: 'WebDriver' object has no attribute '_execute'
This is also an issue when you have the Capture Page Screenshot on fail
If you run robotframework-selenium2library's internal unit tests using Python 2.6 several tests fail due to apparent difference in the assertRaises function between 2.6 and 2.7. Here is a sample test code.
$ hg clone https://code.google.com/p/robotframework/
$ git clone https://github.com/rtomac/robotframework-selenium2library.git
$ virtualenv -p /usr/bin/python2.6 --no-site-packages clean-python26-env
$ source ~/clean-python26-env/bin/activate
(clean-python26-env)$ cd robotframwork
(clean-python26-env)~/robotframwork $ python setup.py install
(clean-python26-env)~/robotframwork $ cd ~/robotframework-selenium2library
(clean-python26-env)~/robotframework-selenium2library $ python test/run_tests.py python *ff
# ... errors...
(clean-python26-env)~/robotframework-selenium2library $ deactivate
A sample error is
ERROR: test_select_with_null_browser (locators.test_windowmanager.WindowManagerTests)
----------------------------------------------------------------------
Traceback (most recent call last):
File "/home/emanlove/s2l-tests/test/unit/locators/test_windowmanager.py", line 19, in test_select_with_null_browser
with self.assertRaises(AssertionError):
TypeError: failUnlessRaises() takes at least 3 arguments (2 given)
Under Python 2.7 (sample test code below) there is no such issues with the unit tests
$ virtualenv -p /usr/bin/python2.7 --no-site-packages clean-python27-env
$ source ~/clean-python27-env/bin/activate
(clean-python27-env)$ cd robotframwork
(clean-python27-env)~/robotframwork $ python setup.py install
(clean-python27-env)~/robotframwork $ deactivate
(clean-python27-env)~/robotframwork $ cd ~/robotframework-selenium2library
(clean-python27-env)~/robotframework-selenium2library $ python test/run_tests.py python *ff
# ... no errors...
(clean-python27-env)~/robotframework-selenium2library $ deactivate
drag and drop keyword missing in selenium2library
I am trying to implement the page object design where , the page is the class and the services offered by the page are methods/functions within that class... I am stuck with partial execution in Robot and method/function calls in python
My Code:
*** Settings ***
Library Selenium2Library
Library xlrd
Library ReadExcel
*** Variables ***
${Test_test_URL} http://stage.Test.com
${Browser} googlechrome
@{Valid Email IDs}
${ExcelFileName} C:\Users\user\Documents\Test\Login\Test_login_email.xls
${ExcelSheetName} DataSet
${EveryEmail} ${EMPTY}
*** Test Cases ***
request an invitation
open browser ${Test_test_URL} ${Browser}
@{Valid Email IDs} read values ${ExcelFileName} ${ExcelSheetName}
: FOR ${EveryEmail} IN @{Valid Email IDs}
\ send an invite ${EveryEmail}
*** Keywords ***
send an invite
[Arguments] ${arg1}
Input Text email ${arg1}
click button SEND
Wait until page contains Thank you - we will contact you! 30
I intent to replace the piece of logic in "Send an Invite" code
(Input Text email ${arg1}
click button SEND)
as a call to a python script with valid email address as the argument. However, How do I pass the browser handle to the python script and how do I receive the browser handle within the python script so I can call functions like driver.find_element_by_id("email")
we would typically do : driver = webdriver.Firefox(); but this would open a new instance... I want the script to work on the existing instance of the browser...
Please help!
I'd love to be able to download this library from PyPI http://pypi.python.org using pip
.
Making this happen should be as easy as running
python setup.py sdist upload
after each release.
using windows,IE8,I use "Alert Should Be Present ",then call 'close browser' Immediately.
This will frequently lead to python.exe crash,like"memory can't be read" error.
I add "sleep 1s" after "Alert Should Be Present ",then it works ok.
I am planning to upgrade the test cases developed using selenium RC with robot framework to Selenium2Library. I just tried the below code using Selenium2Library in robot framework
open browser www.google.co.uk ie
No IE browser instance is opened bubt the test result is saying pass
The samething if i Try
open browser www.google.co.uk firfeox
new firefox instance is opened but no proxy setting is set in th opened browser. Please help me out
A declarative, efficient, and flexible JavaScript library for building user interfaces.
π Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. πππ
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google β€οΈ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.