diff --git a/tests/features/test--then--the-element-should_not-contain-cssproperty.feature b/tests/features/test--then--the-element-should-contain-cssproperty.feature similarity index 50% rename from tests/features/test--then--the-element-should_not-contain-cssproperty.feature rename to tests/features/test--then--the-element-should-contain-cssproperty.feature index f2b5276..020b3ed 100755 --- a/tests/features/test--then--the-element-should_not-contain-cssproperty.feature +++ b/tests/features/test--then--the-element-should-contain-cssproperty.feature @@ -1,13 +1,9 @@ -Feature: An example to test if the element contains a certain expected CSS property or not. +Feature: An example to test if the element contains a certain expected CSS property. As a developer - I want to be able to test if the element contains a certain expected CSS property or not. + I want to be able to test if the element contains a certain expected CSS property. Scenario: Check element if the element contains a certain expected CSS property Given I am on "/test--then--the-element-should_not-contain-cssproperty.html" - When I press "Submit" by attr - Then the "body" element should contain "background-color:white;" - - Scenario: Check element if the element not contains a certain CSS property - Given I am on "/test--then--the-element-should_not-contain-cssproperty.html" - When I press "Submit" by attr - Then the "#uname" element should not contain "border:solid 5px red;" \ No newline at end of file + Then I should see a "body" element by attr + When I press "Submit" + Then the "body" element should contain "background-color:white;" css style \ No newline at end of file diff --git a/tests/step-definitions/webship.js b/tests/step-definitions/webship.js index e6b2e78..28f5786 100755 --- a/tests/step-definitions/webship.js +++ b/tests/step-definitions/webship.js @@ -638,7 +638,20 @@ Then(/^(I|we)* should not see (a|an) "([^"]*)?" element by( its)*( "([^"]*)?")* * Example: Then the "body" element should contain "color:white;" * */ -Then(/^the "([^"]*)?" element should contain "([^"]*)?"$/, function (element, elementCss) { +Then(/^the "([^"]*)?" element should contain "([^"]*)?" css style$/, function (attrValue, elementCss) { + + const hasASpace = attrValue.indexOf(' '); + + var selector = ''; + if((attrValue.startsWith('#') || attrValue.startsWith('.')) && hasASpace == -1){ + selector = attrValue; + } + else if (hasASpace == -1){ + selector = attrValue + ',#' + attrValue + ',.' + attrValue + ',[name=' + attrValue + "]," + '[value="' + attrValue + '"],[placeholder="' + attrValue + '"]'; + } + else if (hasASpace > -1){ + selector ='[value="' + attrValue + '"],[placeholder="' + attrValue + '"]'; + } elementCss = elementCss.replace(";", ''); const cssPropertyArr = elementCss.split(":"); @@ -647,7 +660,7 @@ Then(/^the "([^"]*)?" element should contain "([^"]*)?"$/, function (element, el const propertyVal = cssPropertyArr[1].trim(); this.checkCss = function (browser) { - browser.assert.cssProperty(element, cssProperty, propertyVal); + browser.assert.cssProperty(selector, cssProperty, propertyVal); }; });