Posts

Showing posts from August, 2020

Emulate Chrome Browser into mobile View by Using Selenium part-1

                    WebDriver driver ;           ChromeOptions chromeOptions ;   @BeforeClass     public void Resources()   {                                    System. setProperty ( "webdriver.chrome.driver" , "/Users/abc/Desktop/chromedriver/chromedriver" );   Map<String, String> mobileEmulation = new HashMap<>();     mobileEmulation .put( "deviceName" , "iPhone 6/7/8" );     chromeOptions = new ChromeOptions();   chromeOptions .setExperimentalOption( "mobileEmulation" , mobileEmulation );   driver = new ChromeDriver( chromeOptions );   }

Run Selenium Tests in Internet Explorer

 package com.qa.tests; import org.openqa.selenium.WebDriver; import org.openqa.selenium.ie.InternetExplorerDriver; import org.testng.annotations.BeforeClass; import org.testng.annotations.Test; public class RunTestsInternetExplorer { WebDriver driver; @BeforeClass public void loadResources() { //---------Open in Internet Explorer browser------- //for downloading IE Driver exe file visit "https://www.selenium.dev/downloads/" System.setProperty("webdriver.ie.driver","D://driversBrowser//IEDriverServer_Win32_3.150.1//IEDriverServer.exe"); driver = new InternetExplorerDriver(); } @Test public void navUrlForTest() { for(int i=0;i<50;i++) { driver.get("https://letstryselenium.blogspot.com"); } } }

Run Selenium Tests on Chrome Browser

package com.qa.tests; import org.openqa.selenium.WebDriver; import org.openqa.selenium.chrome.ChromeDriver; import org.testng.annotations.BeforeClass; import org.testng.annotations.Test; public class RunTestsOnChrome { WebDriver driver; @BeforeClass public void loadResources() { //---------Open in chrome browser------- //for downloading chromeDriver exe file visit "https://chromedriver.chromium.org/" System.setProperty("webdriver.chrome.driver", "D://driversBrowser//chromedriver_win32//chromedriver.exe"); driver = new ChromeDriver(); } @Test public void navUrlForTestGA() { for(int i=0;i<50;i++) { driver.get("https://letstryselenium.blogspot.com"); } } }

Write data into excel file by using maven poi dependencies.

Image
 package com.qa.tests; import java.io.File; import java.io.FileInputStream; import java.io.FileOutputStream; import org.apache.poi.ss.usermodel.Cell; import org.apache.poi.ss.usermodel.Row; import org.apache.poi.ss.usermodel.Sheet; import org.apache.poi.ss.usermodel.Workbook; import org.apache.poi.ss.usermodel.WorkbookFactory; public class WriteDataExcel  { public static void main(String[] args) throws Exception { String str="D:\\excel\\Book1.xlsx"; FileInputStream file=new FileInputStream(str); Workbook book = WorkbookFactory.create(file); Sheet sheet = book.getSheetAt(1); for(int i=1;i<=16;i++) { Row row = sheet.createRow(i); for(int j=0;j<2;j++) { Cell cell = row.createCell(j); if(j%2==0) { cell.setCellValue("username"+i); } else { cell.setCellValue("password"+i); } } } file.close(); FileOutputStream fis=new FileOutputStream(new File(str)); book.write(...

Reading data from excel file by using maven poi dependencies.

add this dependencies in maven pom.xml file or visit this site to download latest dependencies https://mvnrepository.com/artifact/org.apache.poi/poi   <dependency>         <groupId>org.apache.poi</groupId>         <artifactId>poi</artifactId>         <version>3.15</version>     </dependency>     <dependency>         <groupId>org.apache.poi</groupId>         <artifactId>poi-ooxml</artifactId>         <version>3.15</version>     </dependency> -------------------------------------------------------------------------------------------------------------------------- package com.qa.tests; import java.io.FileInputStream; import java.io.IOException; import org.apache.poi.EncryptedDocumentException; import org.apache.poi.openxml4j....