Showing posts with label How to pick data from an excel sheet?. Show all posts
Showing posts with label How to pick data from an excel sheet?. Show all posts

How to handle multiple windows in Selenium?


Example of handling Multiple Windows in Selenium:

public static void main(String[] args) throws InterruptedException {
// TODO Auto-generated method stub
WebDriver driver = new FirefoxDriver();
driver.get("https://www.abc.com/");
driver.manage().window().maximize();
String Window1 = driver.getWindowHandle();
driver.findElement(By.linkText("Contact us Now")).click();
for (String Window2 : driver.getWindowHandles())
{
driver.switchTo().window(Window2);
}
driver.findElement(By.xpath("//*[@id='bigin']")).sendKeys("abcde");
Thread.sleep(5000);
driver.close();
driver.switchTo().window(Window1);
driver.getTitle();
Thread.sleep(3000);
driver.close();
}

For more info, Contact Us

How to get data from an Excel sheet?


If you're looking how to pick username and passwords or any data from an excel sheet then below steps will help you out:

1) Download J-Excel jar (What is J-Excel), you can get the path to download J-Excel jar by clicking here
2) Now, add this jar to your build path. You can look for the steps here.
3) Create a new class and add below code:

public class Excel {
static Sheet s ;
 public static void main(String[] args) throws BiffException, IOException {
  
FileInputStream fis = new FileInputStream("C:\\Users\\DELL\\Desktop\\r.xls");
Workbook w = Workbook.getWorkbook(fis);
s = w.getSheet(0);