Skip to content

Commit

Permalink
#146 - Deprecate SelenideAddons.matchAttribute
Browse files Browse the repository at this point in the history
  • Loading branch information
Marcel Pfotenhauer committed Oct 9, 2020
1 parent 33efb02 commit 54d2efc
Showing 1 changed file with 9 additions and 3 deletions.
12 changes: 9 additions & 3 deletions src/main/java/com/xceptance/neodymium/util/SelenideAddons.java
Original file line number Diff line number Diff line change
Expand Up @@ -273,7 +273,7 @@ private static boolean isThrowableCausedBy(final Throwable throwable, Class<? ex
*/
public static Condition matchesValue(String text)
{
return matchValue(text);
return matchValue(".*" + text + ".*");
}

/**
Expand All @@ -291,7 +291,7 @@ public static Condition matchesValue(String text)
*/
public static Condition matchValue(final String regex)
{
return matchesAttribute("value", regex);
return Condition.attributeMatching("value", regex);
}

/**
Expand All @@ -301,13 +301,16 @@ public static Condition matchValue(final String regex)
* Sample: <code>$("input").waitWhile(matchesValue("foo"), 12000)</code>
* </p>
*
* @deprecated Not needed anymore since it's supported by Selenide. Will be removed with the next major version. Use
* com.codeborne.selenide.Condition.attributeMatching instead.

This comment has been minimized.

Copy link
@h-arlt

h-arlt Oct 19, 2020

Contributor

Please link appropriately such that user can directly jump to JavaDoc of referenced method:

{@linkplain com.codeborne.selenide.Condition#attributeMatching}

Please also adjust JavaDoc below.

This comment has been minimized.

Copy link
@occupant23

occupant23 Oct 20, 2020

Contributor

changed it

* @param attributeName
* The name of the attribute that should contain the text
* @param text
* The text that should be contained within the attribute
* @return a Selenide {@link Condition}
* @see #matchAttribute(String, String)
*/
@Deprecated
public static Condition matchesAttribute(String attributeName, String text)
{
return matchAttribute(attributeName, text);
Expand All @@ -320,14 +323,17 @@ public static Condition matchesAttribute(String attributeName, String text)
* Sample: Assert that given element's value attribute matches given regular expression
* <code>$("input").should(matchValue("Hello\s*John"))</code>
* </p>
*
*
* @deprecated Not needed anymore since it's supported by Selenide. Will be removed with the next major version. Use
* com.codeborne.selenide.Condition.attributeMatching instead.
* @param attributeName
* The name of the attribute that should be matched with the regex
* @param regex
* e.g. Kicked.*Chuck Norris - in this case ".*" can contain any characters including spaces, tabs, CR
* etc.
* @return a Selenide {@link Condition}
*/
@Deprecated
public static Condition matchAttribute(final String attributeName, final String regex)
{
return new Condition("match " + attributeName)

This comment has been minimized.

Copy link
@h-arlt

h-arlt Oct 19, 2020

Contributor

Shouldn't it return Condition.attributeMatching(attributeName, regex) instead?

This comment has been minimized.

Copy link
@occupant23

occupant23 Oct 20, 2020

Contributor

Unfortunately not since the functionality is slightly different.

At the moment the regex is done like this:
Pattern.compile("." + regex + ".", DOTALL).matcher(text).matches();

The new function is performing the following:
Pattern.compile(attributeRegex).matcher(element.getAttribute(attributeName)).matches();

So I don't want to break functionalities at the moment. But I will note this in the release notes.

Expand Down

0 comments on commit 54d2efc

Please sign in to comment.