robotframework / SeleniumLibrary

Web testing library for Robot Framework
Apache License 2.0
1.38k stars 758 forks source link

1. "Close Browser" keyword not working in IE,FF.i am using selenium2Library.Please help me in resolving it. #124

Closed PriyaAn closed 11 years ago

PriyaAn commented 11 years ago

I am getting the following error

10:09:00.790 FAIL URLError: <urlopen error [Errno 10061] No connection could be made because the target machine actively refused it>

10:09:00.791 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>

10:09:00.850 FAIL WindowsError: [Error 5] Access is denied

srib4ufrnd commented 11 years ago

I too getting this error. Please help me.

Currently i removed this keyword from my robot test code, i am not getting any error, but obviously my PC is filled with many browsers, as i am not closing them.

I would like to know answer for one question, please some one clarify me

when i am using the keyword selenium2library.Close Browser, why there is an invocation for the keyword "Capture page screen shot"

will this error occurs when i use "close browser" keyword in combination with "capture page screen shot" ?

because in my test code i am using "capture page screen shot" keyword and later after using few keywords i am finally using "close browser" keyword, is this an issue by any chance?

i felt like "capture page screen shot" keyword is taking some time to capture the snapshot, meanwhile the close browser window is called, which interupts the "capture page screen shot" keyword in taking snapshot. This might throw an windows error saying "as windows cannot provide access to an application which is already closed" . This is my wage guess, need to see in the selenium python code to find out what really is happening for both of the above keywords.

know1nos commented 11 years ago

i believe that is an issue, i use the close window command instead, works fine

ombre42 commented 11 years ago

What version of Selenium are you using? There's a known bug in 2.25 that causes this.

srib4ufrnd commented 11 years ago

hello " know1nos" thanks for ur suggestion. The "close window" selenium keyword is working fine us now. For time being we are using it.

srib4ufrnd commented 11 years ago

hello "ombre42" we are cuurently using "robotframework-selenium2library-1.0.1" version. we are cross checking the bug correction as u suggested, it is not so clear how to patch. we will cross check once again and will get back. Thank u for ur suggestion :-)

PriyaAn commented 11 years ago

Thanks for the inputs "srib4ufrnd" and "know1nos". i am also facing an issue of executing test on jybot.Can some one help me in this?

srib4ufrnd commented 11 years ago

Hello "PriyaAn", currently we are using firefox web browser. so we had robot framework installed and selenium2library and we had firefox driver installed. We also traced back The fix which was suggested by "ombre42" but this fix is clearly expalining for IE driver only i guess. hello "ombre42" could u please provide ur valuable comment on this? will this fix works for firefox web driver also? because i did not find any file with name "service.py" in firefox web driver folder.

"PriyaAn" if u r using IE browser then the fix suggested by "ombre42" works for u i guess. please find the links below to fix it.

main link: http://code.google.com/p/selenium/issues/detail?id=4310 Fix explanation link: http://code.google.com/p/selenium/source/detail?r=17705 (click on the modification link this will show u which code snippet to remove and which code snippet to add)

coming to the final thing, where u can find the "service.py" file so that u can modify the code? well u can find the file in the below possible path in ur PC C:\Python27\Lib\site-packages\selenium-2.25.0-py2.7.egg\selenium\webdriver\ie

if u want to see for all the web drivers just go a folder up i.e C:\Python27\Lib\site-packages\selenium-2.25.0-py2.7.egg\selenium\webdriver

ombre42 commented 11 years ago

@PriyaAn: Selenium does not work under jybot as it requires Python >= 2.6 and Jython only supports version 2.5. Some people have reported success using a hacked webdriver and others have used alpha versions of Jython 2.7.

I have not had experience with this issue. I would suggest simply trying an older version of selenium to see if that changes anything. pip uninstall selenium pip install selenium==2.21.3 I had to update pip from 1.0.2 to get this to work right (was ignoring version and using cached version).

The code for FF looks similar to IE maybe suffering from the same issue

srib4ufrnd commented 11 years ago

Thank u "ombre42". we modified the code as u suggested. It is working fine.

as u said FF is also suffering from the same issue during browser kill :-)

so we tried the same fix for IE during browser kill in the FF also during browser kill and it is working fine.

Just for more info:

Filepath: C:\Python27\Lib\site-packages\selenium-2.25.0-py2.7.egg\selenium\webdriver\firefox

File name: firefox_binary.py

Previous code: def kill(self): """Kill the browser.

    This is useful when the browser is stuck.
    """
    if self.process:
            self.process.kill()
            self.process.wait()

Code changed:

def kill(self): """Kill the browser.

    This is useful when the browser is stuck.
    """
    try:
        if self.process:
            self.process.kill()
            self.process.wait()
    except WindowsError:
        # kill may not be available under windows environment
        pass

we added the same windows error exception in FF web driver Kill() method. Thanks a lot once again. Now we replaced "close window" keyword with "close browser" keyword in all our robot scripts. So far going good....all our scripts are working fine and PASS. we are not getting the "capture page screen shot" error now :-)

PriyaAn commented 11 years ago

Hi @srib4ufrnd, @ombre42 , thanks for the updates.But, the solution for "close browser" suggested above is int working for me. Firstly change in webdriver->firefox->firefox_binary.py is not working for me. Secondly i am still facing the issues if i update webdriver->ie/chrome->service.py file.Error in this case is as follows:

17:58:22.237 FAIL No browser is open 17:58:22.237 WARN Keyword 'Capture Page Screenshot' could not be run on failure: No browser is open 17:58:22.237 FAIL No browser is open

Could you please check why it is happening?

srib4ufrnd commented 11 years ago

Hi @PriyaAn , We tried this (i mean we ran our scripts) by having all the below preconditions. Dont know how it is related but can just give a try.

  1. close all the existing browsers before u run the scripts from RIDE
  2. Disable system level proxy settings. (in case if u have any proxy server configuration)
srib4ufrnd commented 11 years ago

one more info @PriyaAn for chrome i did not do any fix in the chromes web driver for "close browser" keyword, it is working directly with out any modfications in chrome driver and in IE we are facing the same issue as mentioned by you. we are also checking it. but in firefox everything is working fine with the fix.No errors occured.

we are currently focusing more on firefox. can u tell me what is the exact error u r getting in firefox, if ur error is related to some encoding of python file, then try modifying the firefox_binary.py file with proper python IDE editor, as i faced this issue when i edited the python file with notepad++ and saved it.

PriyaAn commented 11 years ago

Sure @srib4ufrnd ,will check it once more and will update you.

ombre42 commented 11 years ago

@PriyaAn it seems as if Open Browser failed as it said no browser is open? Close All Browsers would suffer from the issue title here, but should not fail because there are no browsers open as your log output indicates.

PriyaAn commented 11 years ago

Hi @srib4ufrnd ,Yes you were right.I tried to edit it on python editor this time its working fine for ie and chrome(no changes required). But for ff as i made changes in firefox_binary.py,Selenium2Library is not recognized by RIDE.

srib4ufrnd commented 11 years ago

for firefox_binary.py also modify with python IDE only (use TCL TK IDLE editor) it is working fine. As i also got the same error and i used the above editor. it is working fine now. the selenium2library is getting recognized now.

srib4ufrnd commented 11 years ago

The error we got in IE for info sake: URLError: <urlopen error [Errno 10061] No connection could be made because the target machine actively refused it> [ WARN ] Keyword 'Capture Page Screenshot' could not be run on failure: No browser is open

in IE we got the above error with "close window" keyword. Now it is working fine with the FIX. Thank u @ombre42 .

emanlove commented 11 years ago

As per @srib4ufrnd comments above this issue appears fixed. Please reopen ticket if this is not the case.