Skip to content

Get Windows XXX / Select Window Breaks on IE8 / Win 7, FF works fine #10

Closed

Description

@adwu73

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.

Activity

  1. adwu73 commented on Nov 30, 2011

    @adwu73
    ContributorAuthor

    16:08:51.334 DEBUG Traceback (most recent call last):
    File "C:\Python27\lib\site-packages\robot\running\timeouts.py", line 85, in run
    return runner.get_result()
    File "C:\Python27\lib\site-packages\robot\utils\robotthread.py", line 37, in run
    self._result = self.runnable()
    File "C:\Python27\lib\site-packages\robot\utils\robotthread.py", line 28, in
    self.runnable = lambda: runnable((args or ()), *
    (kwargs or {}))
    File "", line 2, in get_window_titles
    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 142, in get_window_titles
    return self._log_list(self._window_manager.get_window_titles(self._current_browser()))
    File "C:\Python27\lib\site-packages\Selenium2Library\locators\windowmanager.py", line 23, in get_window_titles
    return [ window_info[3] for window_info in self._get_window_infos(browser) ]
    File "C:\Python27\lib\site-packages\Selenium2Library\locators\windowmanager.py", line 92, in _get_window_infos
    window_infos.append(browser.get_current_window_info())
    File "C:\Python27\lib\site-packages\Selenium2Library\webdrivermonkeypatches.py", line 26, in get_current_window_info
    for att in atts ]

  2. adwu73 commented on Dec 1, 2011

    @adwu73
    ContributorAuthor

    Hi there, I did more test today, and find some temp solutions, I will try to test in the real app tomorrow. Now the work around works for my test app. Since I don't really understand python code, I hope someone can help me out here.

    For the trace above, I found out the code in trouble is this line in webdrivermonkeypatches.py around line 26:
    atts = [ att if att is not None and len(att) else 'undefined'
    for att in atts ]

    I don't understand the logic here, it seems like some kind of error proof code here. When I tried to remove this two lines completely, my IE test case succeeded.

    I add an Execute Javascirpt | return [ window.id, window.name, document.title, document.location ]; into my test script, I found that the IE and Firefox return is different, I am not sure whether the differences caused the trouble:

    Here is the IE output:
    None, '', u'Login', <selenium.webdriver.remote.webelement.WebElement object at 0x027991B0>

    Here is the FireFox output:
    [None, '', u'Login', {u'search': '', u'assign': u'function assign() {\n [native code]\n}', u'hash': '', u'hostname': u'zdiles.chaosnet.org', u'replace': u'function replace() {\n [native code]\n}', u'reload': u'function reload() {\n [native code]\n}', u'host': u'zdiles.chaosnet.org', u'href': u'http://zdiles.chaosnet.org/index.php', u'pathname': u'/index.php', u'protocol': u'http:', u'port': ''}]

    I hope this can be helpful for someone that can really fix this issue from the root, tks!!!

  3. retailernet commented on Mar 22, 2012

    @retailernet

    The cause appears to be triggered by document.location parameter in the execute_script call on line 24.
    atts = self.execute_script("return [ window.id, window.name, document.title, document.location ];")

    IE driver returns a web element object but Firefox driver returns a dictionary:

    IE driver returns
    [None, '', u'Page Title', <selenium.webdriver.remote.webelement.WebElement object at 0x01807EB0>]

    Firefox driver returns
    [None, '', u'Page Title', {u'search': '', u'assign': u'function assign() {\n [native code]\n}', u'hash': '', u'hostname': u'host.domain', u'replace': u'function replace() {\n [native code]\n}', u'reload': u'function reload() {\n [native code]\n}', u'host': u'host.domain', u'href': u'http://qtst.atpco.org/fmhome/login.jsp', u'pathname': u'/path/to/file.html', u'protocol': u'http:', u'port': ''}]

    Since "Select Window" keyword offers locator options for name, title & url can you change line 24 to:
    atts = self.execute_script("return [ window.id, window.name, document.title, document.url ];")

    This tested ok for me on IE & Chrome and trusting this reference
    http://www.w3schools.com/jsref/prop_doc_url.asp it appears document.url is supported by all browser versions

    Hope this helps

  4. adwu73 commented on Mar 23, 2012

    @adwu73
    ContributorAuthor

    tks I will modify the code and give a try

  5. adwu73 commented on Mar 24, 2012

    @adwu73
    ContributorAuthor

    I have tested the fix, it works for my simple test case, not sure this change other behaviours of the system, I will test this fix in real test code next week

  6. stevejefferies commented on Jul 11, 2012

    @stevejefferies
    Contributor

    I have also observed this issue on IE9/Win7 and can confirm that the fix suggested by retailernet fixes this issue.

  7. added a commit that references this issue on Aug 31, 2012
  8. emanlove commented on Nov 6, 2012

    @emanlove
    Member

    Fix released under version 1.1 Selenium2Library.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions