-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathAssignment198.java
More file actions
67 lines (42 loc) · 1.84 KB
/
Assignment198.java
File metadata and controls
67 lines (42 loc) · 1.84 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
package TestNGCLAssignments;
import java.io.FileInputStream;
import java.io.IOException;
import org.apache.poi.EncryptedDocumentException;
import org.apache.poi.ss.usermodel.Workbook;
import org.apache.poi.ss.usermodel.WorkbookFactory;
import org.openqa.selenium.By;
import org.openqa.selenium.WebDriver;
import org.openqa.selenium.WebElement;
import org.openqa.selenium.firefox.FirefoxDriver;
import org.openqa.selenium.interactions.Actions;
import org.testng.Assert;
import org.testng.annotations.Test;
//WAP to logout from amazon & find out if the testcase is pass or fail;
public class Assignment198 {
WebDriver driver;
@Test
public void amazlogout() throws EncryptedDocumentException, IOException, InterruptedException {
FileInputStream f1 = new FileInputStream(
"C:\\Users\\USER\\eclipse-workspace\\SeleniumBasics\\DDT\\Abhilash.xlsx");
Workbook w1 = WorkbookFactory.create(f1);
String un = w1.getSheet("Sheet4").getRow(0).getCell(0).getStringCellValue();
String pswd = w1.getSheet("Sheet4").getRow(0).getCell(1).getStringCellValue();
driver = new FirefoxDriver();
driver.get("https://amazon.in");
driver.manage().window().maximize();
driver.findElement(By.xpath("//a[@id='nav-link-accountList']")).click();
Thread.sleep(2000);
driver.findElement(By.name("email")).sendKeys(un);
driver.findElement(By.className("a-button-input")).click();
Thread.sleep(2000);
driver.findElement(By.name("password")).sendKeys(pswd);
driver.findElement(By.id("signInSubmit")).click();
WebElement o1 = driver.findElement(By.xpath("//a[@id='nav-link-accountList']"));
Actions a1 = new Actions(driver);
a1.moveToElement(o1).perform();
Thread.sleep(2000);
driver.findElement(By.xpath("//span[.='Sign Out']")).click();
WebElement s2 = driver.findElement(By.name("email"));
Assert.assertEquals(s2.isDisplayed(), true,"sorry");
}
}