Repository navigation
Expand file tree
/
Copy pathAutomation_Web_Exc.java
More file actions
59 lines (43 loc) · 1.81 KB
/
Copy pathAutomation_Web_Exc.java
File metadata and controls
59 lines (43 loc) · 1.81 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
package com.tasks;
import java.util.Random;
import org.openqa.selenium.By;
import org.openqa.selenium.WebDriver;
import org.openqa.selenium.WebElement;
import org.openqa.selenium.chrome.ChromeDriver;
import org.openqa.selenium.edge.EdgeDriver;
import org.testng.annotations.AfterTest;
import org.testng.annotations.BeforeTest;
import org.testng.annotations.Test;
public class Automation_Web_Exc {
WebDriver driver= new ChromeDriver();
String URLWEB="https://automationexercise.com/";
String publicEmail;
@BeforeTest
public void mySetUp() {
driver.get(URLWEB);
driver.manage().window().maximize();
}
@Test (enabled = true,invocationCount = 2)
public void SignUpAutomation_EXC(){
driver.navigate().to("https://automationexercise.com/signup");
String [] usernames= {"rahaf","marwa","rababah","sara","lolo","momo","nono"};
System.out.println(usernames.length);
Random rand = new Random();
int randomIndex= usernames.length;
int randomNumber= rand.nextInt(1000);
String randomUsername = usernames[rand.nextInt(randomIndex)]+randomNumber ;
String email=randomUsername +"@gmail.com";
publicEmail=email;
WebElement NameSignUp = driver.findElement(By.xpath("//input[@placeholder='Name']"));
NameSignUp.sendKeys(randomUsername);
WebElement EmailField= driver.findElement(By.xpath("//input[@data-qa='signup-email']"));
EmailField.sendKeys(email);
WebElement signUPButton= driver.findElement(By.xpath("//button[@data-qa='signup-button']"));
signUPButton.click();
}
@AfterTest
public void afterMyTest() throws InterruptedException {
Thread.sleep(2000);
driver.quit();
}
}