SeleniumLibrary icon indicating copy to clipboard operation
SeleniumLibrary copied to clipboard

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

Open PriyaAn opened this issue 14 years ago • 18 comments

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

PriyaAn avatar Sep 28 '12 04:09 PriyaAn

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.

srib4ufrnd avatar Oct 04 '12 10:10 srib4ufrnd

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

know1nos avatar Oct 05 '12 20:10 know1nos

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

ombre42 avatar Oct 06 '12 14:10 ombre42

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

srib4ufrnd avatar Oct 08 '12 10:10 srib4ufrnd

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 :-)

srib4ufrnd avatar Oct 08 '12 10:10 srib4ufrnd

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?

PriyaAn avatar Oct 08 '12 10:10 PriyaAn

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

srib4ufrnd avatar Oct 08 '12 10:10 srib4ufrnd

@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

ombre42 avatar Oct 08 '12 17:10 ombre42

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 :-)

srib4ufrnd avatar Oct 09 '12 06:10 srib4ufrnd

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?

PriyaAn avatar Oct 09 '12 12:10 PriyaAn

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 avatar Oct 09 '12 13:10 srib4ufrnd

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.

srib4ufrnd avatar Oct 09 '12 13:10 srib4ufrnd

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

PriyaAn avatar Oct 09 '12 13:10 PriyaAn

@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.

ombre42 avatar Oct 09 '12 13:10 ombre42

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.

PriyaAn avatar Oct 09 '12 13:10 PriyaAn

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 avatar Oct 09 '12 13:10 srib4ufrnd

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 .

srib4ufrnd avatar Oct 10 '12 15:10 srib4ufrnd

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

emanlove avatar Dec 11 '12 15:12 emanlove