Repository navigation
Expand file tree
/
Copy pathLikeCalculator
More file actions
48 lines (35 loc) · 1.5 KB
/
Copy pathLikeCalculator
File metadata and controls
48 lines (35 loc) · 1.5 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
import org.openqa.selenium.By;
import org.openqa.selenium.WebElement;
import com.testsigma.customfunc.common.CustomTestStep;
import com.testsigma.customfunc.common.TestsigmaCustomFunctions;
import com.testsigma.customfunc.result.ResultConstants;
import com.testsigma.customfunc.result.TestStepResult;
public class likesCalculator extends TestsigmaCustomFunctions{
@CustomTestStep
public TestStepResult calculator() throws Exception{
String noofLikes=driver.findElement(By.className("boat-stats__icon-group")).getText();
int a =Integer.parseInt(noofLikes);
try {
WebElement Like=driver.findElement(By.xpath("//div[@class='boat-details-header__button']"));
Like.click();
}
catch(Exception e) {
TestStepResult result=new TestStepResult();
result.setStatus(ResultConstants.FAILURE);
result.setMessage("Click Didnt Happen on Like Button");
}
Thread.sleep(10000);
String noofLikespostclick=driver.findElement(By.className("boat-stats__icon-group")).getText();
int b=Integer.parseInt(noofLikespostclick);
TestStepResult result=new TestStepResult();
int c=b-a;
if(c==1) {
System.out.println("Like Increased/Decreased by One");
}
result.setStatus(ResultConstants.SUCCESS);
result.setMessage("Number of Likes before Click="+ noofLikes);
result.setMessage("Number of Likes After Clicking on Like button is ="+ noofLikespostclick);
result.setMessage("Verifed Click increased or Decreased by" + c);
return result;
}
}