-
Notifications
You must be signed in to change notification settings - Fork 87
Expand file tree
/
Copy pathArticle.java
More file actions
48 lines (40 loc) · 1.24 KB
/
Article.java
File metadata and controls
48 lines (40 loc) · 1.24 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
package objects;
import org.openqa.selenium.By;
import org.openqa.selenium.WebElement;
import java.util.Objects;
public class Article {
private Image img;
private String tag;
private Link link;
public Article(Image img, String tag, Link link) {
this.img = img;
this.tag = tag;
this.link = link;
}
public Article(WebElement element) {
this.img = new Image(element.findElement(By.cssSelector("img")));
this.tag = element.findElement(By.cssSelector("span")).getText();
this.link = new Link(element.findElement(By.cssSelector("a")));
}
@Override
public boolean equals(Object o) {
if (this == o) return true;
if (o == null || getClass() != o.getClass()) return false;
Article article = (Article) o;
return Objects.equals(img, article.img) &&
Objects.equals(tag, article.tag) &&
Objects.equals(link, article.link);
}
@Override
public int hashCode() {
return Objects.hash(img, tag, link);
}
@Override
public String toString() {
return "Article{" +
"img=" + img +
", tag='" + tag + '\'' +
", link=" + link +
'}';
}
}