Selenium

Difference between / and // in XPath / is used to create absolute XPath which starts from root. This is highly brittle since any changes to UI will change element locator. // is used to create relative XPath . The XPath is created relative to another element in UI Difference between driver.get() and driver.navigate().to() Both driver.get() and driver.navigate().to() will try to open a webpage and wait for the page to load. It means, it will wait till Onload event has fired. But it will not wait for all AJAX calls to trigger and process. Both of them are essentially the same. How ever Navigate() interface exposes the ability to move backward and forward in browser history. ...

June 22, 2015

Java - Writing Into specific cell in Excel

In my previous blog post , I have mentioned how to read from an excel file using jxl jar files in Java. It can be found here In this post, I will explain how to write into an excel using same library. Below example will update the excel cell content with the value passed and also update its formatting . The color of the cell will change depending on value we pass. We can use similar functions for updating any other cell format. ...

June 10, 2014

Java - Reading a specific cell in Excel

Below is a code snippet for reading a specific cell from Excel using Java. It is done by using importing jxl jar files which can be found here. Import below in class file import jxl.Cell; import jxl.Sheet; import jxl.Workbook; import jxl.format.Colour; import jxl.read.biff.BiffException; import jxl.write.*; Below is function for reading value from specific cell in Excel public String readexcel(String sheet, int intRow, int intCol){ try { //Create a workbook object from the file at specified location. //Change the path of the file as per the location on your computer. Workbook wrk1 = Workbook.getWorkbook(new File(dataPath)); //Obtain the reference to the first sheet in the workbook Sheet sheet1 = wrk1.getSheet(sheet); //Obtain reference to the Cell using getCell(int col, int row) method of sheet // Add " - 1" to both intRow , intCol depending how whether we consider excel start with row & column number as 0 or 1 Cell colArow1 = sheet1.getCell(intRow , intCol ); //Read the contents of the Cell using getContents() method, which will return //it as a String String strReturn = colArow1.getContents(); return strReturn; /* //Display the cell contents System.out.println("Contents of cell Col A Row 1: \""+str_colArow1 + "\""); System.out.println("Contents of cell Col B Row 1: \""+str_colBrow1 + "\""); System.out.println("Contents of cell Col A Row 2: \""+str_colArow2 + "\"");*/ } catch (BiffException e) { e.printStackTrace(); } catch (IOException e) { e.printStackTrace(); } return sheet; } Below is an example of how to read from a cell based on row number and Column NAME ...

June 1, 2014

Hello world

Redirect

May 21, 2014