-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathFox1.java
More file actions
120 lines (76 loc) · 3.78 KB
/
Copy pathFox1.java
File metadata and controls
120 lines (76 loc) · 3.78 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
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
package pom;
import java.io.File;
import java.io.IOException;
import java.util.concurrent.TimeUnit;
import org.openqa.selenium.By;
import org.openqa.selenium.OutputType;
import org.openqa.selenium.TakesScreenshot;
import org.openqa.selenium.WebDriver;
import org.openqa.selenium.WebElement;
import org.openqa.selenium.chrome.ChromeDriver;
import org.openqa.selenium.interactions.Actions;
import org.openqa.selenium.io.FileHandler;
public class Fox1 {
public static void main(String[] args) throws IOException{
String [] fn= {"sweety","sofy","rosey","dolly","rocky"};
String [] ln= {"sweet","sof","rose","doll","rock"};
String [] eid= {"sweety@gmail.com","sofy@gmail.com","rosey@gmail.com","dolly@gmail.com","rocky@gmail.com"};
String [] tn= {"45678978","198376452","1234567845","78563445674","567856345645"};
String [] pwd= {"sweety@gmail.com1S","sofy@gmail.com2S","rosey@gmail.com1R","dolly@gmail.com1D","rocky@gmail.com2R"};
String [] cpwd= {"sweety@gmail.com1S","sofy@gmail.com2S","rosey@gmail.com1R","dolly@gmail.com1D","rocky@gmail.com2R"};
String title="Register Account";
// Set the path to the chromedriver executable
System.setProperty("webdriver.chrome.driver", "./drivers/chromedriver.exe");
// Create a new instance of the Chrome driver
WebDriver driver = new ChromeDriver();
//window maximization and adding implicit value
driver.manage().window().maximize();
driver.manage().timeouts().implicitlyWait(20, TimeUnit.SECONDS);
//using action to perform actions
Actions action=new Actions(driver);
//to take screen shot
TakesScreenshot ts = (TakesScreenshot)driver;
// Navigate to the given url
driver.get("https://tutorialsninja.com/demo/index.php?route=account/login");
// Find the input fields and test
for(int i=0;i<5;i++)
{
//click the register link
driver.findElement(By.linkText("Register")).click();
driver.findElement(By.id("input-firstname")).sendKeys(fn[i]);
driver.findElement(By.id("input-lastname")).sendKeys(ln[i]);
driver.findElement(By.id("input-email")).sendKeys(eid[i]);
driver.findElement(By.id("input-telephone")).sendKeys(tn[i]);
driver.findElement(By.id("input-password")).sendKeys(pwd[i]);
driver.findElement(By.id("input-confirm")).sendKeys(cpwd[i]);
if(i%2==0)
{
WebElement radiono=driver.findElement(By.xpath("//*[@id=\"content\"]/form/fieldset[3]/div/div/label[2]/input"));
action.click(radiono).perform();
}
else
{
WebElement radioyes=driver.findElement(By.xpath("//*[@id=\"content\"]/form/fieldset[3]/div/div/label[1]/input"));
action.click(radioyes).perform();
}
WebElement checkbox= driver.findElement(By.xpath("//*[@id=\"content\"]/form/div/div/input[1]"));
action.click(checkbox).perform();
// Click the signup button
driver.findElement(By.xpath("//*[@id=\"content\"]/form/div/div/input[2]")).click();
if(title.contentEquals(title))
{
System.out.println("signup failed for "+(i+1)+"details given");
File destination = new File ("./errorshot/image1.png");
File webpageScreenshot = ts.getScreenshotAs(OutputType.FILE);
FileHandler.copy(webpageScreenshot, destination);
}
else
{
System.out.println("signup pass for "+(i+1)+"details given");
driver.findElement(By.linkText("Logout")).click();
}
}
// Close the browser
driver.quit();
}
}