Module 2 - Assignment
Module 2 - Assignment
Assignment -1(WebTable):
➤ url : https://demo.guru99.com/test/web-table-element.php
package Module2;
import java.util.List;
import org.openqa.selenium.By;
import org.openqa.selenium.WebDriver;
import org.openqa.selenium.WebElement;
import org.openqa.selenium.chrome.ChromeDriver;
driver.get("https://demo.guru99.com/test/web-table-element.php");
for(WebElement name:row)
}
driver.close();
➤ url : https://demo.guru99.com/test/login.html
➤ Enter email
➤ Enter password
package Module2;
import org.openqa.selenium.By;
import org.openqa.selenium.WebDriver;
import org.openqa.selenium.chrome.ChromeDriver;
driver .get("https://demo.guru99.com/test/login.html");
driver.findElement(By.xpath("//input[@id=\"email\"]")).sendKeys("Admin");
driver.findElement(By.name("passwd")).sendKeys("admin123");
driver.findElement(By.name("SubmitLogin")).click();
➤https://demo.guru99.com/test/delete_customer.php
➤ Enter customer Id
➤ Click on Submit
package Module2;
import org.openqa.selenium.Alert;
import org.openqa.selenium.By;
import org.openqa.selenium.WebDriver;
import org.openqa.selenium.WebElement;
import org.openqa.selenium.chrome.ChromeDriver;
driver.manage().window().maximize();
driver.get("https://demo.guru99.com/test/delete_customer.php");
Thread.sleep(1000);
driver.findElement(By.name("cusid")).sendKeys("C_01");
driver.findElement(By.name("submit")).click();
Thread.sleep(1000);
System.out.println(alerts.getText());
Thread.sleep(1000);
alerts.accept();
//second alert
System.out.println(alerts.getText());
Thread.sleep(1000);
alerts.accept();
driver.close();
Assignment -2.1(Frames):
➤https://demo.guru99.com/test/delete_customer.php
package Module2;
import org.openqa.selenium.By;
import org.openqa.selenium.WebDriver;
import org.openqa.selenium.chrome.ChromeDriver;
driver.get("https://demo.guru99.com/test/guru99home/");
driver.manage().window().maximize();
driver.switchTo().frame("a077aa5e");
Thread.sleep(3000);
driver.findElement(By.xpath("html/body/a/img")).click();
Assignment -2.2(Windows):
➤url : http://demo.guru99.com/popup.php
➤ Click on Submit
package Module2;
import java.util.Iterator;
import java.util.Set;
import org.openqa.selenium.By;
import org.openqa.selenium.WebDriver;
import org.openqa.selenium.chrome.ChromeDriver;
driver.get("https://demo.guru99.com/popup.php");
driver.findElement(By.linkText("Click Here")).click();
String parent=driver.getWindowHandle();
Iterator<String> it=handles.iterator();
while(it.hasNext())
{
String Child_window=it.next();
if(!parent.equals(Child_window))
driver.switchTo().window(Child_window);
driver.findElement(By.name("emailid")).sendKeys("admin@123");
driver.findElement(By.name("btnLogin")).click();
driver.close();
driver.switchTo().window(parent);
➤url : https://jqueryui.com/
➤ Click on Draggable
package Module2;
import java.io.File;
import java.io.IOException;
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.Action;
import org.openqa.selenium.interactions.Actions;
import org.openqa.selenium.io.FileHandler;
driver.manage().window().maximize();
driver.get("https://jqueryui.com/");
driver.findElement(By.linkText("Draggable")).click();
driver.switchTo().frame(frames);
act.moveToElement(source).clickAndHold().moveByOffset(100, 100).perform();
captureScreenshot("Drag");
driver.close();
//screenshot