user1512496
user1512496

Reputation: 61

Error occurs during executing the examples of selenium with Robot Framework

on my system I had Python 2.6 and Robot framework. I have installed Selenium2Library by following the directions according to the link below: https://github.com/rtomac/robotframework-selenium2library but when I try to run the example, its giving me the following error and no firefox window opened.

ERROR:  clean-python26-env]$ python testExeJS.py 
======================================================================
ERROR: test_exe_javascript (__main__.ExecuteJavascriptTestCase)
----------------------------------------------------------------------

Traceback (most recent call last):
  File "testExeJS.py", line 7, in setUp
    selenium.setTimeout("60000")
NameError: global name 'selenium' is not defined

----------------------------------------------------------------------
Ran 1 test in 0.000s

FAILED (errors=1)

Any help is really apreciated

Edit

I am Sorry I just saw your reply. may be this will help you more to understand my problem. The example code link is: `http://www.wallix.org/2011/07/26/how-to-use-robotframework-with-the-selenium-library/

and my running errors are:

$ pybot myFirstTest.txt 

==============================================================================
myFirstTest :: This is your first test                                        
==============================================================================
[ WARN ] Keyword 'Capture Page Screenshot' could not be run on failure: No browser is open
Go To Google Page [Documentation] Go to google page and search som... | FAIL |
WebDriverException: Message: 'The browser appears to have exited before we could connect. The output was: Error: no display specified\n'
------------------------------------------------------------------------------
[ WARN ] Keyword 'Capture Page Screenshot' could not be run on failure: No browser is open
Open Selenium Page [Documentation] TestCase for open Selenium page    | FAIL |
No browser is open
------------------------------------------------------------------------------
myFirstTest :: This is your first test                                | FAIL |
2 critical tests, 0 passed, 2 failed
2 tests total, 0 passed, 2 failed
==============================================================================
Output:  /data/home/sadikhan/ironport/Selenium/output.xml
Log:     /data/home/sadikhan/ironport/Selenium/log.html
Report:  /data/home/sadikhan/ironport/Selenium/report.html

Upvotes: 3

Views: 6674

Answers (1)

theheadofabroom
theheadofabroom

Reputation: 22029

ok so here I'm going to annotate the log so that hopefully you can see how to read it and debug from it in the future. I apologise for any inaccuracies, as I'#m used to Selenium2Library:

$ pybot myFirstTest.txt 
==============================================================================
myFirstTest :: This is your first test                                        
==============================================================================
[ WARN ] Keyword 'Capture Page Screenshot' could not be run on failure: No browser is open

Ok so here's your first clue - selenium is trying to take a screenshot but doesn't see a browser open - you you see a browser open? Does it open to the correct page?

Go To Google Page [Documentation] Go to google page and search som... | FAIL |
WebDriverException: Message: 'The browser appears to have exited before we could connect. The output was: Error: no display specified\n'

So here's the next clue - The browser appears to have exited before we could connect. The output was: Error: no display specified - so this points to the problem being that you're running headless, and SeleniumLibrary expects to find a display (please correct me if I'm wrong) so you may need to create one, which is rather easier than it might sound - you will want to install PyVirtualDisplay and then from robotframework - try using | Library | pyvirtualdisplay.smartdisplay.SmartDisplay | before using SeleniumLibrary.

------------------------------------------------------------------------------
[ WARN ] Keyword 'Capture Page Screenshot' could not be run on failure: No browser is open

And here's the first clue again.

Open Selenium Page [Documentation] TestCase for open Selenium page    | FAIL |
No browser is open

And this is because of the earlier problems.

------------------------------------------------------------------------------
myFirstTest :: This is your first test                                | FAIL |
2 critical tests, 0 passed, 2 failed
2 tests total, 0 passed, 2 failed
==============================================================================
Output:  /data/home/sadikhan/ironport/Selenium/output.xml
Log:     /data/home/sadikhan/ironport/Selenium/log.html
Report:  /data/home/sadikhan/ironport/Selenium/report.html

Upvotes: 1

Related Questions