SCANNER | Selenium
import java.util.Scanner;
import java.util.concurrent.TimeUnit;
import org.openqa.selenium.By;
import org.openqa.selenium.WebDriver;
import org.openqa.selenium.firefox.FirefoxDriver;
import org.testng.annotations.AfterTest;
import org.testng.annotations.BeforeTest;
import org.testng.annotations.Test;
public class classname {
private WebDriver driver;
private String baseUrl;
private int a, i;
@BeforeTest
public void setUp() throws Exception {
int a;
Scanner in = new Scanner(System.in);
driver = new FirefoxDriver();
System.out.println("Please choose the Environment: \n");
System.out.println("1. DEV Environment");
System.out.println("2. QA Environment");
System.out.println("3. PROD Environment");
a = in.nextInt();
if (a == 1) {
System.out.println("You have selected 'DEV Environment' ...\n");
driver.get("http://dev-xyz.com/");
}
if (a == 2) {
System.out.println("You have selected 'QA Environment' ...\n");
driver.get("http://qa-xyz.com/");
}
if (a == 3) {
System.out
.println("You have selected 'PROD Cloud Environment' ...\n");
driver.get("http://prod-xyz.com/");
}
in.close();
driver.manage().timeouts().implicitlyWait(3, TimeUnit.SECONDS);
}
@Test
public void Test01() throws Exception {
// your code here...
}
@AfterTest
public void tearDown() throws Exception {
driver.quit();
}
}
Hi Prashanth sams ,
ReplyDeleteYour blog is really cool and refreshing. I would suggest you create driver object right after the the input processing. This will ensure the focus on both console and browser.
//input processing
a = in.nextInt();
in.close();
driver = new FirefoxDriver();
Thank you..
ReplyDeleteIt helped me a lot..!!
this code will not be run
ReplyDeletecurry 9
ReplyDeleteoff white hoodie
hermes outlet