Get Windows XXX / Select Window Breaks on IE8 / Win 7, FF works fine
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.
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
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!!!
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
tks I will modify the code and give a try
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
I have also observed this issue on IE9/Win7 and can confirm that the fix suggested by retailernet fixes this issue.
Fix released under version 1.1 Selenium2Library.