[arquillian-issues] [JBoss JIRA] (ARQGRA-290) testAttributeIsPresent fails on Chrome and PhantomJS

Juraj Húska (JIRA) jira-events at lists.jboss.org
Wed Mar 27 09:12:42 EDT 2013


    [ https://issues.jboss.org/browse/ARQGRA-290?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=12763452#comment-12763452 ] 

Juraj Húska edited comment on ARQGRA-290 at 3/27/13 9:12 AM:
-------------------------------------------------------------

IMHO there is problem in how {{WebDriver}} returns the value of some attribute. In those mentioned tests specifically of attribute {{style}}.

The {{style="display: none;"}} attribute is removed in order to make an element visible by JS code in the HTML pages of those tests: [here|https://github.com/arquillian/arquillian-graphene/blob/master/graphene-webdriver/graphene-webdriver-ftest/src/test/resources/org/jboss/arquillian/graphene/ftest/wait/sample.html#L14-L21].

The condition for asserting an attribute present is [here|https://github.com/arquillian/arquillian-graphene/blob/master/graphene-webdriver/graphene-webdriver-impl/src/main/java/org/jboss/arquillian/graphene/condition/attribute/AttributeIsPresent.java#L40].
So we are asserting the returned value to {{null}}.

Copying relevant part of the {{WebDriver#getAttribute}} method's Javadoc:

??Get the value of a the given attribute of the element. Will return the current value, even if this has been modified after the page has been loaded. More exactly, this method will return the value of the given attribute, unless that *attribute is not present*, in which case the *value of the property with the same name is returned.* *If neither value is set, null is returned.* The *"style"* attribute is converted as best can be to a text representation with a trailing semi-colon.??

Therefore, I think that we need to change the assertion of the {{AttributeIsPresent}} condition to be in compliance with the {{getAttribute}} method.

*However*, that would not be sufficient. Another problem is that there is difference in JS engines of {{HTMLUnit}} and {{Chrome}}, which causes that removing an attribute is not consistent for all browsers.

IMHO the best option would be to assert element for presence like this:
{{return (attributeValue != null) && (attributeValue.length() != 0) && (!attributeValue.equals(getAttribute()));}}

What do you think guys ?


                
      was (Author: jhuska):
    IMHO there is problem in how {{WebDriver}} returns the value of some attribute. In those mentioned tests specifically of attribute {{style}}.

The {{style="display: none;"}} attribute is removed in order to make an element visible by JS code in the HTML pages of those tests: [here|https://github.com/arquillian/arquillian-graphene/blob/master/graphene-webdriver/graphene-webdriver-ftest/src/test/resources/org/jboss/arquillian/graphene/ftest/wait/sample.html#L14-L21].

The condition for asserting an attribute present is [here|https://github.com/arquillian/arquillian-graphene/blob/master/graphene-webdriver/graphene-webdriver-impl/src/main/java/org/jboss/arquillian/graphene/condition/attribute/AttributeIsPresent.java#L40].
So we are asserting the returned value to {{null}}.

Copying relevant part of the {{WebDriver#getAttribute}} method's Javadoc:

??Get the value of a the given attribute of the element. Will return the current value, even if this has been modified after the page has been loaded. More exactly, this method will return the value of the given attribute, unless that *attribute is not present*, in which case the *value of the property with the same name is returned.* *If neither value is set, null is returned.* The *"style"* attribute is converted as best can be to a text representation with a trailing semi-colon.??

Therefore, I think that we need to change the assertion of the {{AttributeIsPresent}} condition to be in compliance with the {{getAttribute}} method.

*However*, that would not be sufficient. Another problem is that there is difference in JS engines of {{HTMLUnit}} and {{Chrome}}, which causes that removing an attribute is not consistent for all browsers.

IMHO the best option would be to assert element for presence like this:
{{return (attributeValue != null) && (attributeValue.length() != 0) && (attributeValue.equals(getAttribute()));}}

What do you think guys ?


                  
> testAttributeIsPresent fails on Chrome and PhantomJS
> ----------------------------------------------------
>
>                 Key: ARQGRA-290
>                 URL: https://issues.jboss.org/browse/ARQGRA-290
>             Project: Arquillian Graphene
>          Issue Type: Bug
>            Reporter: Lukáš Fryč
>            Assignee: Juraj Húska
>            Priority: Critical
>             Fix For: 2.0.0.Alpha4
>
>
> Test cases:
> {code}
> LocatorAttributeTest.testAttributeIsPresent
> LocatorAttributeTest.testAttributeIsPresentDirectly
> WebElementAttributeTest.testAttributeIsPresent
> WebElementAttributeTest.testAttributeIsPresentDirectly
> ConditionsTestCase.testAttributeIsPresent
> {code}

--
This message is automatically generated by JIRA.
If you think it was sent incorrectly, please contact your JIRA administrators
For more information on JIRA, see: http://www.atlassian.com/software/jira



More information about the arquillian-issues mailing list