/* Program to demo parameterization using text file */
/*Text File is stored in path "D:\\Selenium\\Programs\\Class\\Parameter.txt " */
/*Data inside text is in the format "2,3,4" -meaning to click links at the bottom 2,3,4 form the website "http://www.rtt.ag/en" */
import org.openqa.selenium.By;
import org.openqa.selenium.WebDriver;
import org.openqa.selenium.firefox.FirefoxDriver;
import java.io.BufferedReader;
import java.io.DataInputStream;
import java.io.FileInputStream;
import java.io.IOException;
import java.io.InputStreamReader;
import java.util.regex.Pattern;
public class Para
{
public static void main(String[] args) throws IOException, InterruptedException
{
String strLine;
//int iTemp;
WebDriver driver = new FirefoxDriver();
driver.get("http://www.rtt.ag/en/");
//driver.manage().window().maximize();
FileInputStream fstream = new FileInputStream("D:\\Selenium\\Programs\\Class\\Parameter.txt");
DataInputStream in = new DataInputStream(fstream);
BufferedReader br = new BufferedReader(new InputStreamReader(in));
while ((strLine = br.readLine()) != null )
{
strLine = strLine.trim();
//if ((strLine.length()!=0) && (strLine.charAt(0)!='#')) {
String[] students = strLine.split(",");
//for (int i=0 ; i<students.length-1 ; i++ )
for (int i=0 ; i<students.length ; i++ )
{
//driver.findElement(By.xpath("//*[@id='footer']/div[1]/div[2]/div/div[1]/ul/li["+students[i]+"]/a")).
driver.findElement(By.xpath("//*[@id='footer']/div[1]/div[2]/div/div[1]/ul/li["+students[i]+"]/a")).click();
Thread.sleep(1000);
}
}
driver.quit();
}
}
/*Text File is stored in path "D:\\Selenium\\Programs\\Class\\Parameter.txt " */
/*Data inside text is in the format "2,3,4" -meaning to click links at the bottom 2,3,4 form the website "http://www.rtt.ag/en" */
import org.openqa.selenium.By;
import org.openqa.selenium.WebDriver;
import org.openqa.selenium.firefox.FirefoxDriver;
import java.io.BufferedReader;
import java.io.DataInputStream;
import java.io.FileInputStream;
import java.io.IOException;
import java.io.InputStreamReader;
import java.util.regex.Pattern;
public class Para
{
public static void main(String[] args) throws IOException, InterruptedException
{
String strLine;
//int iTemp;
WebDriver driver = new FirefoxDriver();
driver.get("http://www.rtt.ag/en/");
//driver.manage().window().maximize();
FileInputStream fstream = new FileInputStream("D:\\Selenium\\Programs\\Class\\Parameter.txt");
DataInputStream in = new DataInputStream(fstream);
BufferedReader br = new BufferedReader(new InputStreamReader(in));
while ((strLine = br.readLine()) != null )
{
strLine = strLine.trim();
//if ((strLine.length()!=0) && (strLine.charAt(0)!='#')) {
String[] students = strLine.split(",");
//for (int i=0 ; i<students.length-1 ; i++ )
for (int i=0 ; i<students.length ; i++ )
{
//driver.findElement(By.xpath("//*[@id='footer']/div[1]/div[2]/div/div[1]/ul/li["+students[i]+"]/a")).
driver.findElement(By.xpath("//*[@id='footer']/div[1]/div[2]/div/div[1]/ul/li["+students[i]+"]/a")).click();
Thread.sleep(1000);
}
}
driver.quit();
}
}
No comments:
Post a Comment