inherit Selenium2Library,Multiple keywords with name 'Capture Page Screenshot' found

1,429 views
Skip to first unread message

wingk...@126.com

unread,
Jul 19, 2012, 11:25:57 PM7/19/12
to robotframe...@googlegroups.com
create my lib:

from Selenium2Library import Selenium2Library
from robot.libraries.BuiltIn import BuiltIn

class nnlib1(Selenium2Library):
    
    def __init__(self,*args):
        Selenium2Library.__init__(self)

    
    def open(self,url,browser='ie'):

        Selenium2Library.open_browser(self,url,browser)
        BuiltIn().sleep(2)
        if browser == 'ie' :
            Selenium2Library.click_element(self,'id=overridelink')
            
    def login(self,name='admin',pwd='123456'):
   
        Selenium2Library.input_text(self,'id=hitxtUserName',name)
        Selenium2Library.input_text(self,'id=hipwd',pwd)
        Selenium2Library.click_element(self,'id=ibLogin')    
        BuiltIn().wait_until_keyword_succeeds('1 min','10 sec','location_should_contain','frameDefault.htm')

the last sentence run error :
Multiple keywords with name 'location_should_contain' found.
Give the full name of the keyword you want to use.
Found: 'Selenium2Library.Location Should Contain' and 'nnlib1.Location Should Contain'

and :
[ WARN ] Keyword 'Capture Page Screenshot' could not be run on failure: Multiple keywords with name 'Capture Page Screenshot' found.
Give the full name of the keyword you want to use.
Found: 'Selenium2Library.Capture Page Screenshot' and 'nnlib1.Capture Page Screenshot'

what should i do ?
thanks.

        

Bryan Oakley

unread,
Jul 20, 2012, 6:34:10 AM7/20/12
to robotframe...@googlegroups.com
Is your test case importing both Selenium2Library and your nnlib1?
> --
> You received this message because you are subscribed to the Google Groups
> "robotframework-users" group.
> To view this discussion on the web visit
> https://groups.google.com/d/msg/robotframework-users/-/XNkmr3qe0nkJ.
> To post to this group, send email to robotframe...@googlegroups.com.
> To unsubscribe from this group, send email to
> robotframework-u...@googlegroups.com.
> For more options, visit this group at
> http://groups.google.com/group/robotframework-users?hl=en.

Ян Габис

unread,
Nov 28, 2013, 10:44:47 AM11/28/13
to robotframe...@googlegroups.com
Sorry for necroposting, but i want to recommend much more "robotic" solution. In your case it's much better not to imort Selenium2Library and get it as an object in your class, but to get it's instance with builtin keyword/method.
As an example:

from robot.libraries.BuiltIn import BuiltIn

class _YourKeywords:
    @property
    def s2l(self):
        return BuiltIn().get_library_instance('Selenium2Library')

    def open(self,url,browser='ie'):

        s2l.open_browser(self,url,browser)
        BuiltIn().sleep(2)
        if browser == 'ie' :
            s2l.click_element(self,'id=overridelink')


In that case you won't have duplicate keywords in your test libs and your code would be smoother.

Regards,
Yan.
Reply all
Reply to author
Forward
0 new messages