ASSIGNMENT-11
A2 SLOT
Course Program: Int. M. Tech
Course code: SWE-3006
Course Title: Advance Software Testing
Batch:2020-2025
Submitted to
Dr.Umamaheswari E
Submitted by
Sathish Kumar V- 20MIS1080
VTOP Login:
CODE:
package lab11;
import org.openqa.selenium.By;
import org.openqa.selenium.firefox.FirefoxDriver;
public class test {
public static void main(String[] args)
{
System.setProperty("webdriver.gecko.driver","C:\\Users\\sathi\\Downloads\\geckodriver-
v0.33.0-win64\\geckodriver.exe");
// FirefoxOptions options = new FirefoxOptions();
FirefoxDriver driver= new FirefoxDriver();
driver.get("https://vtopcc.vit.ac.in/vtop/login");
driver.findElement(By.name("username")).sendKeys("20MIS1080");
driver.findElement(By.id("password")).sendKeys("vit");
driver.findElement(By.id("submitBtn")).click();
driver.quit();
}
Example ( for id and name):
import org.openqa.selenium.By;
import org.openqa.selenium.firefox.FirefoxDriver;
public class firstlastest {
public static void main(String[] args)
{
System.setProperty("webdriver.gecko.driver","E:\\gecko\\geckodriver.e
xe");
// FirefoxOptions options = new FirefoxOptions();
FirefoxDriver driver= new FirefoxDriver();
driver.get("https://www.facebook.com");
driver.findElement(By.id("email")).sendKeys("Advance Software
testing");
driver.findElement(By.name("pass")).sendKeys("vit");
driver.findElement(By.name("login")).click();
driver.quit();
}
Example xpath
import org.openqa.selenium.By;
import org.openqa.selenium.firefox.FirefoxDriver;
public class xpath {
public static void main(String[] args)
{
System.setProperty("webdriver.gecko.driver","E:\\gecko\\geckodriver.e
xe");
// FirefoxOptions options = new FirefoxOptions();
FirefoxDriver driver= new FirefoxDriver();
driver.get("https://www.google.com");
driver.findElement(By.xpath("//*[@id=\"APjFqb\"]")).sendKeys("vit");
driver.findElement(By.xpath("/html/body/div[1]/div[3]/form/div[1]/div[1]/di
v[4]/center/input[1]")).click();
driver.quit();
}
}
Example – drop down menu
package latestversion;
import org.openqa.selenium.By;
import org.openqa.selenium.WebElement;
import org.openqa.selenium.firefox.FirefoxDriver;
import org.openqa.selenium.support.ui.Select;
public class drop {
public static void main(String[] args)
{
System.setProperty("webdriver.gecko.driver","E:\\gecko\\geckodriver.e
xe");
// FirefoxOptions options = new FirefoxOptions();
FirefoxDriver driver= new FirefoxDriver();
driver.get("https://www.facebook.com/register");
Select drop1 = new
Select(driver.findElement(By.id("month")));
Select drop2= new
Select(driver.findElement(By.id("day")));
drop2.selectByIndex(3);
drop1.selectByVisibleText("Mar");
driver.quit();
}
Example –get() & getText()
package lab11;
import org.openqa.selenium.By;
import org.openqa.selenium.WebElement;
import org.openqa.selenium.firefox.FirefoxDriver;
public class title {
public static void main(String[] args)
{
System.setProperty("webdriver.gecko.driver","C:\\Users\\sathi\\Downloads\\geckodri
ver-v0.33.0-win64\\geckodriver.exe");
// FirefoxOptions options = new FirefoxOptions();
FirefoxDriver driver= new FirefoxDriver();
driver.get("https://www.facebook.com");
System.out.println("Page title is : " + driver.getTitle());
WebElement element1=driver.findElement(By.name("login"));
System.out.println("button text is : " + element1.getText());
driver.quit();
}
}