0% found this document useful (0 votes)
47 views2 pages

Selenium Web Driver Exercises

This document contains code snippets from Selenium WebDriver exercises. The first code block launches a FirefoxDriver, navigates to two websites, and selects an option from a dropdown menu. The second and third code blocks launch FirefoxDriver and ChromeDriver instances, navigate to different pages, and interact with alerts. The code demonstrates basic Selenium commands for launching browsers, navigating pages, finding elements, and handling alerts.
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
47 views2 pages

Selenium Web Driver Exercises

This document contains code snippets from Selenium WebDriver exercises. The first code block launches a FirefoxDriver, navigates to two websites, and selects an option from a dropdown menu. The second and third code blocks launch FirefoxDriver and ChromeDriver instances, navigate to different pages, and interact with alerts. The code demonstrates basic Selenium commands for launching browsers, navigating pages, finding elements, and handling alerts.
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd

Advanced Software Testing lab

Selenium Web driver exercise

NAME:GUNASEKHAR R
REG NO:16MIS1175

1st

package astlab;

import org.openqa.selenium.By;
import org.openqa.selenium.WebDriver;
import org.openqa.selenium.firefox.FirefoxDriver;
import org.openqa.selenium.support.ui.Select;
public class program1 {
public static void main(String args[] ){
System.setProperty("webdriver.gecko.driver","C:\\software\\geckodriver\\geckodriver.exe");
   WebDriver driver = new FirefoxDriver();
   driver.get("https://moodlecc.vit.ac.in/");
   driver.findElement(By.partialLinkText("Forgotten")).click();
   driver.findElement(By.partialLinkText("mobile")).click();
   WebDriver driver2 = new FirefoxDriver();
   driver2.get("https://www.caterpillar.com/en.html");
   Select drpCountry = new Select(driver.findElement(By.xpath("/html/body/form/select")));
   drpCountry.selectByVisibleText("HTML");
}
}

Second &Third

package astlab;

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.firefox.FirefoxDriver;
public class PROGRAM2 {
public static void main(String[] args) {
System.setProperty("webdriver.gecko.driver","C:\\software\\geckodriver\\geckodriver.exe");
       WebDriver driver =new FirefoxDriver();
       driver.get("https://moodlecc.vit.ac.in/login/index.php");
    
       System.setProperty("webdriver.gecko.driver","C:\\software\\geckodriver\\geckodriver.exe");
       WebDriver driver1 =new FirefoxDriver();
       driver.get("https://www.w3schools.com/js/tryit.asp?filename=tryjs_alert");
    
       driver.switchTo().alert().accept();
        
   
System.setProperty("webdriver.chrome.driver","C:\\software\\geckodriver\\chromedriver.exe");
       WebDriver driver2 =new ChromeDriver();
       driver1.get("https://www.hotstar.com/in");
    
    
}
}

You might also like