diff --git a/src/main/java/com/redhat/darcy/webdriver/locators/ByAttribute.java b/src/main/java/com/redhat/darcy/webdriver/locators/ByAttribute.java index e7f0b77..4d9ba45 100644 --- a/src/main/java/com/redhat/darcy/webdriver/locators/ByAttribute.java +++ b/src/main/java/com/redhat/darcy/webdriver/locators/ByAttribute.java @@ -75,7 +75,29 @@ public WebElement findElement(SearchContext context) { public int hashCode() { return toString().hashCode(); } - + + @Override + public boolean equals(Object obj) { + if (this == obj) + return true; + if (!super.equals(obj)) + return false; + if (getClass() != obj.getClass()) + return false; + ByAttribute other = (ByAttribute) obj; + if (attribute == null) { + if (other.attribute != null) + return false; + } else if (!attribute.equals(other.attribute)) + return false; + if (word == null) { + if (other.word != null) + return false; + } else if (!word.equals(other.word)) + return false; + return true; + } + @Override public String toString() { return "ByAttribute(\"" + attribute + "\"): " + word; diff --git a/src/main/java/com/redhat/darcy/webdriver/locators/ByPartialAttribute.java b/src/main/java/com/redhat/darcy/webdriver/locators/ByPartialAttribute.java index 418a8e3..ecd24e7 100644 --- a/src/main/java/com/redhat/darcy/webdriver/locators/ByPartialAttribute.java +++ b/src/main/java/com/redhat/darcy/webdriver/locators/ByPartialAttribute.java @@ -52,12 +52,34 @@ public WebElement findElement(SearchContext context) { return ((FindsByXPath) context).findElementByXPath(".//*[" + attributeContains(attribute, word) + "]"); } - + @Override public int hashCode() { return toString().hashCode(); } - + + @Override + public boolean equals(Object obj) { + if (this == obj) + return true; + if (!super.equals(obj)) + return false; + if (getClass() != obj.getClass()) + return false; + ByPartialAttribute other = (ByPartialAttribute) obj; + if (attribute == null) { + if (other.attribute != null) + return false; + } else if (!attribute.equals(other.attribute)) + return false; + if (word == null) { + if (other.word != null) + return false; + } else if (!word.equals(other.word)) + return false; + return true; + } + @Override public String toString() { return "ByPartialAttribute(\"" + attribute + "\"): " + word; diff --git a/src/main/java/com/redhat/darcy/webdriver/locators/ByPartialVisibleText.java b/src/main/java/com/redhat/darcy/webdriver/locators/ByPartialVisibleText.java index 06265e4..3f73ab9 100644 --- a/src/main/java/com/redhat/darcy/webdriver/locators/ByPartialVisibleText.java +++ b/src/main/java/com/redhat/darcy/webdriver/locators/ByPartialVisibleText.java @@ -54,12 +54,29 @@ public WebElement findElement(SearchContext context) { return ((FindsByXPath) context).findElementByXPath(".//*[" + textContains(text) + "]"); } - + @Override public int hashCode() { return toString().hashCode(); } - + + @Override + public boolean equals(Object obj) { + if (this == obj) + return true; + if (!super.equals(obj)) + return false; + if (getClass() != obj.getClass()) + return false; + ByPartialVisibleText other = (ByPartialVisibleText) obj; + if (text == null) { + if (other.text != null) + return false; + } else if (!text.equals(other.text)) + return false; + return true; + } + @Override public String toString() { return "ByPartialVisibleText: " + text; diff --git a/src/main/java/com/redhat/darcy/webdriver/locators/ByPartialVisibleTextIgnoreCase.java b/src/main/java/com/redhat/darcy/webdriver/locators/ByPartialVisibleTextIgnoreCase.java index 2a5cc7b..80b4832 100644 --- a/src/main/java/com/redhat/darcy/webdriver/locators/ByPartialVisibleTextIgnoreCase.java +++ b/src/main/java/com/redhat/darcy/webdriver/locators/ByPartialVisibleTextIgnoreCase.java @@ -50,12 +50,29 @@ public WebElement findElement(SearchContext context) { return ((FindsByXPath) context).findElementByXPath(".//*[" + textContainsIgnoringCase(text) + "]"); } - + @Override public int hashCode() { return toString().hashCode(); } - + + @Override + public boolean equals(Object obj) { + if (this == obj) + return true; + if (!super.equals(obj)) + return false; + if (getClass() != obj.getClass()) + return false; + ByPartialVisibleTextIgnoreCase other = (ByPartialVisibleTextIgnoreCase) obj; + if (text == null) { + if (other.text != null) + return false; + } else if (!text.equals(other.text)) + return false; + return true; + } + @Override public String toString() { return "ByPartialVisibleTextIgnoreCase: " + text; diff --git a/src/main/java/com/redhat/darcy/webdriver/locators/ByVisibleText.java b/src/main/java/com/redhat/darcy/webdriver/locators/ByVisibleText.java index 90656e0..caa77a0 100644 --- a/src/main/java/com/redhat/darcy/webdriver/locators/ByVisibleText.java +++ b/src/main/java/com/redhat/darcy/webdriver/locators/ByVisibleText.java @@ -65,12 +65,34 @@ public List findElements(SearchContext context) { return result; } - + @Override public int hashCode() { return toString().hashCode(); } - + + @Override + public boolean equals(Object obj) { + if (this == obj) + return true; + if (!super.equals(obj)) + return false; + if (getClass() != obj.getClass()) + return false; + ByVisibleText other = (ByVisibleText) obj; + if (byPartialVisibleText == null) { + if (other.byPartialVisibleText != null) + return false; + } else if (!byPartialVisibleText.equals(other.byPartialVisibleText)) + return false; + if (text == null) { + if (other.text != null) + return false; + } else if (!text.equals(other.text)) + return false; + return true; + } + @Override public String toString() { return "ByVisibleText: " + text; diff --git a/src/main/java/com/redhat/darcy/webdriver/locators/ByVisibleTextIgnoreCase.java b/src/main/java/com/redhat/darcy/webdriver/locators/ByVisibleTextIgnoreCase.java index fb4c55a..dbe4b57 100644 --- a/src/main/java/com/redhat/darcy/webdriver/locators/ByVisibleTextIgnoreCase.java +++ b/src/main/java/com/redhat/darcy/webdriver/locators/ByVisibleTextIgnoreCase.java @@ -67,12 +67,35 @@ public List findElements(SearchContext context) { return result; } - + @Override public int hashCode() { return toString().hashCode(); } - + + @Override + public boolean equals(Object obj) { + if (this == obj) + return true; + if (!super.equals(obj)) + return false; + if (getClass() != obj.getClass()) + return false; + ByVisibleTextIgnoreCase other = (ByVisibleTextIgnoreCase) obj; + if (byPartialVisibleTextIgnoreCase == null) { + if (other.byPartialVisibleTextIgnoreCase != null) + return false; + } else if (!byPartialVisibleTextIgnoreCase + .equals(other.byPartialVisibleTextIgnoreCase)) + return false; + if (text == null) { + if (other.text != null) + return false; + } else if (!text.equals(other.text)) + return false; + return true; + } + @Override public String toString() { return "ByVisibleTextIgnoreCase: " + text;