"cannot access execution context' throw out when I ca.. BuildIn().get_library_instance('SeleniumLibrary')

520 views
Skip to first unread message

Geri

unread,
Nov 28, 2017, 12:40:15 PM11/28/17
to robotframework-users
I upgrade the SeleniumLibrary from Selenium2Library, after that BuildIn().get_library_instance('SeleniumLibrary') doesn't work

my test code is like this

from robot.libraries.BuiltIn import BuiltIn

def test2():
seleniumlib = BuiltIn().get_library_instance('SeleniumLibrary')
print 'done'

if __name__ == "__main__":
test2()

C:\apps\Python27\python.exe C:/Automation/RF/Lib/test2.py
Traceback (most recent call last):
  File " C:/Automation/RF/Lib/test2.py", line 12, in <module>
    test2()
  File " C:/Automation/RF/Lib/test2.py", line 4, in test2
    seleniumlib = BuiltIn().get_library_instance('SeleniumLibrary')
  File "C:\apps\Python27\lib\site-packages\robot\libraries\BuiltIn.py", line 3254, in get_library_instance
    return self._namespace.get_library_instance(name)
  File "C:\apps\Python27\lib\site-packages\robot\libraries\BuiltIn.py", line 71, in _namespace
    return self._get_context().namespace
  File "C:\apps\Python27\lib\site-packages\robot\libraries\BuiltIn.py", line 66, in _get_context
    raise RobotNotRunningError('Cannot access execution context')
robot.libraries.BuiltIn.RobotNotRunningError: Cannot access execution context
Process finished with exit code 1


Any idea? why?

Thanks





Tatu Aalto

unread,
Nov 28, 2017, 1:03:36 PM11/28/17
to ying...@gmail.com, robotframework-users
Ugh

I think when you run the code, you are running it without Robot Framework and there the RobotNotRunning error is raised. If you call the test2 method as a keyword from a test case, then the code should work fine. Also the exception does not have anything to do with SeleniumLibrary.

-Tatu
Send from my mobile


--
You received this message because you are subscribed to the Google Groups "robotframework-users" group.
To unsubscribe from this group and stop receiving emails from it, send an email to robotframework-users+unsub...@googlegroups.com.
To post to this group, send email to robotframework-users@googlegroups.com.
Visit this group at https://groups.google.com/group/robotframework-users.
For more options, visit https://groups.google.com/d/optout.

Geri

unread,
Nov 28, 2017, 1:24:05 PM11/28/17
to robotframework-users
hmm, even I run the test with RF, still not working.

To post to this group, send email to robotframe...@googlegroups.com.
Auto Generated Inline Image 1

Geri

unread,
Nov 28, 2017, 1:32:43 PM11/28/17
to robotframework-users
hmm,  not very sure, but if I changed it to BuiltIn().get_library_instance('Selenium2Library'), it works.  Why I cannot use SeleniumLibrary?

Tatu Aalto

unread,
Nov 28, 2017, 1:44:39 PM11/28/17
to ying...@gmail.com, robotframework-users
One can use SeleniumLibrary, did you remember to import the SeleniumLibrary also?


-Tatu
Send from my mobile
To unsubscribe from this group and stop receiving emails from it, send an email to robotframework-users+unsubscrib...@googlegroups.com.

To post to this group, send email to robotframe...@googlegroups.com.
Visit this group at https://groups.google.com/group/robotframework-users.
For more options, visit https://groups.google.com/d/optout.

--
You received this message because you are subscribed to the Google Groups "robotframework-users" group.
To unsubscribe from this group and stop receiving emails from it, send an email to robotframework-users+unsub...@googlegroups.com.
To post to this group, send email to robotframework-users@googlegroups.com.
Reply all
Reply to author
Forward
0 new messages