This blog is for Automation Test Engineers

Friday 16 March 2018

Writing data into excel sheet


FileInputStream fis=new FileInputStream("E:\\data.xlsx");              Workbook wb=WorkbookFactory.create(fis);
Sheet s=wb.getSheet("test");//sheet name
s.createRow(1).createCell(1).setCellValue("Java");
FileOutputStream fos = new  FileOutputStream("E:\\data.xlsx");
 wb.write(fos);
 fos.close();
System.out.println("Success");



                 }


2

How to click on Hyperlink

WebDriver driver= new FirefoxDriver();
driver.get("https://www.google.com"):
driver.findElement(By.linkText("ಕನ್ನಡ")).click();

0

Different types of navigation command


1)driver.navigate().back(): This command takes back the user to previous page of the application.
2)driver.navigate().forward(): This command navigates the user to next page of application
3)driver.navigate().refresh(); This command refreshes the current webpage
4)driver.navigate().to():This command allows the user to launch a new web browser window and navigates to specified URL
Eg:
driver.navigate().to("https://www.google.co.in/");


0

How to enter semicolon

String keys=keys.chord(Keys.SHIFT, Keys.SEMICOLON);

0

How to press Shift+Tab


String keys=keys.chord(Keys.SHIFT, Keys.TAB);

0

How do u read text from hidden element

First we should move cursor over element where element is hidden and we can use getText() method to get the text from hidden element

0

Windows scroll up/down


WebDriver driver= new FirefoxDriver();
driver.get("https://www.flipkart.com/"):
JavascriptExceutor js=new JavascriptExceutor ();
//scroll up
js.executeScript("window.scrollBy(0,450)","");
//scroll down
js.executeScript("window.scrollBy(450,0)","");

0