question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

New Keyword 'Element Attriubte Should Contain'

See original GitHub issue

Copied from ExtendeSelenium2Library:

@keyword
    def element_attribute_should_contain(self, attribute_locator, expected, message=''):
        """Verifies element attribute identified by ``attribute_locator`` contains ``expected``.

        Arguments:
        - ``attribute_locator``: The locator to find requested element attribute. It consists of
                                 element locator followed by an @ sign and attribute name,
                                 for example "element_id@class".
        - ``expected``: The expected element attribute value.
        - ``message``: The value that would be use to override the default error message.

        Examples:
        | Element Attribute Should Contain | css=div.class@class | value |
        """
        actual = self.get_element_attribute(attribute_locator)
        if expected not in actual:
            if not message:
                message = "Element attribute '%s' should have contained '%s'" \
                          " but its value was '%s'." % (attribute_locator, expected, actual)
            raise AssertionError(message)

#And the negation:
 @keyword
    def element_attribute_should_not_contain(self, attribute_locator, unexpected, message=''):
        """Verifies element attribute identified by ``attribute_locator``
        does not contain ``unexpected``.

        Arguments:
        - ``attribute_locator``: The locator to find requested element attribute. It consists of
                                 element locator followed by an @ sign and attribute name,
                                 for example "element_id@class".
        - ``unexpected``: The unexpected element attribute value.
        - ``message``: The value that would be use to override the default error message.

        Examples:
        | Element Attribute Should Not Contain | css=div.class@class | value |
        """
        actual = self.get_element_attribute(attribute_locator)
        if unexpected in actual:
            if not message:
                message = "Element attribute '%s' should not contain '%s'" \
                          " but it did." % (attribute_locator, unexpected)
            raise AssertionError(message)

Issue Analytics

  • State:open
  • Created 5 years ago
  • Comments:9 (8 by maintainers)

github_iconTop GitHub Comments

1reaction
rubygeekcommented, May 25, 2018

Plus, my team has already added Element Attribute Value Should Be - https://github.com/robotframework/SeleniumLibrary/blob/master/src/SeleniumLibrary/keywords/element.py#L387

On Fri, May 25, 2018 at 3:39 AM, Pekka Klärck notifications@github.com wrote:

I can see ES2L supporting the latest SL being useful to many, but, to be honest, if the reason E2SL exists is to just add new generic functionality to SL, I don’t see the point of the library in general. Much better concentrating efforts to SL only.

The situation with AngularLibrary is different because it is designed to a specific domain and adds non-generic functionality on top of SL. Having a way such functionality could be added to SL via plugins might be even better, but that would first require designing and implementing the plugin API.

— You are receiving this because you are subscribed to this thread. Reply to this email directly, view it on GitHub https://github.com/robotframework/SeleniumLibrary/issues/1129#issuecomment-391983835, or mute the thread https://github.com/notifications/unsubscribe-auth/AAAoXSkoBXeGhnAk2jHAXvZsFklxHw41ks5t18M5gaJpZM4UI8TP .

– Ruby: http://blog.rubygeek.com - http://www.twitter.com/rubygeek http://www.linkedin.com/in/nolastowe - my linkedin profile http://github.com/rubygeek - my code

0reactions
pekkaklarckcommented, May 25, 2018

I can see ES2L supporting the latest SL being useful to many, but, to be honest, if the reason E2SL exists is to just add new generic functionality to SL, I don’t see the point of the library in general. Much better concentrating efforts to SL only.

The situation with AngularLibrary is different because it is designed to a specific domain and adds non-generic functionality on top of SL. Having a way such functionality could be added to SL via plugins might be even better, but that would first require designing and implementing the plugin API.

Read more comments on GitHub >

github_iconTop Results From Across the Web

SeleniumLibrary
All keywords support finding elements based on id and name attributes, but some keywords support additional attributes or other values that make ...
Read more >
How to use "Run Keywork If" and "Get Element Attribute" in ...
Let me know what happens. I'm guessing elementPresent will contain only true or false? Ah sorry I just read further, so basically your...
Read more >
XML library | Robocorp documentation
The element to whom to add the new element is specified using source and xpath . They have exactly the same semantics as...
Read more >
AppiumLibrary - GitHub Pages
New in AppiumLibrary 1.4, id and xpath are not required to be ... In contrast to Element Should Contain Text, this keyword does...
Read more >
Keyword Documentation - Robot Framework Hub
Keywords Arguments Documentation Add Location Strategy strategy_name, strategy_keyword, persist=False Capture Page Screenshot filename=selenium‑screenshot‑.png Close Browser Closes the curr...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found