Tag: selenium webdriver

使用Apache POI的Java Selenium – 读取一个Excel文件将这两个行拉在一起

我已经使用下面的代码( 参考链接 )从Excel文件中读取数据,并使用两个单元格中的数据来searchGoogle网站。 但是,程序运行时,两行数据放在search框中,而不是在单独的迭代中一个接一个,因为我期望通过使用For循环。 期待帮助。 这里是代码: package readdatafile; import java.io.*; import java.util.concurrent.TimeUnit; import org.apache.poi.xssf.usermodel.XSSFSheet; import org.apache.poi.xssf.usermodel.XSSFWorkbook; import org.openqa.selenium.By; import org.openqa.selenium.WebDriver; import org.openqa.selenium.WebElement; import org.openqa.selenium.chrome.ChromeDriver; // import org.openqa.selenium.firefox.FirefoxDriver; public class DataDrivenUsingExcelFile { String reafilefrom = "I:\\2000 QA\\Testing Tools\\Selenium\\Examples\\TestData\\testdata.xlsx"; public static void main(String[] args) throws IOException { DataDrivenUsingExcelFile obj1 = new DataDrivenUsingExcelFile(); System.setProperty("webdriver.chrome.driver", "C://ChromeDriverForSelenium/chromedriver.exe"); WebDriver driver = […]

org.apache.poi.openxml4j.exceptions.InvalidOperationException:无法打开指定的文件:

我得到这个错误的数据驱动testing与excel.I已经添加了POI Jar.Below的3.6版本是错误: org.apache.poi.openxml4j.exceptions.InvalidOperationException: Can't open the specified file: 'C:\Users\pjadhav1\AppData\Local\Temp\poifiles\poi-ooxml-747722852.tmp' at org.apache.poi.openxml4j.opc.ZipPackage.<init>(ZipPackage.java:102) at org.apache.poi.openxml4j.opc.OPCPackage.open(OPCPackage.java:199) at org.apache.poi.openxml4j.opc.OPCPackage.open(OPCPackage.java:178) at org.apache.poi.util.PackageHelper.open(PackageHelper.java:53) at org.apache.poi.xssf.usermodel.XSSFWorkbook.<init>(XSSFWorkbook.java:176) at com.iopendr.xls.read.Xls_Reader.<init>(Xls_Reader.java:32) at com.iopendr.test.DriverScript.start(DriverScript.java:96) at com.iopendr.test.DriverScript.main(DriverScript.java:60) 1560 [main] DEBUG devpinoyLogger – *********INITIALIZE ALL TESTCASES IN***********Login Exception in thread "main" java.lang.NullPointerException at com.iopendr.xls.read.Xls_Reader.getRowCount(Xls_Reader.java:43) at com.iopendr.test.DriverScript.start(DriverScript.java:106) at com.iopendr.test.DriverScript.main(DriverScript.java:60)

从xls读取数据,使xls文件在selenium中损坏

我正在尝试从一个正在使用的xls读取数据 java.io.File f1=new java.io.File("E:/SELENIUM DATA/First_P1/DATA_SHEET.xls"); w = Workbook.getWorkbook(f1); wworkbook = Workbook.createWorkbook(f1,w); 过了一段时间,如果试图打开xls,显示文件已损坏。 帮我。

如何覆盖我以前的Excel文件使用JXL?

我想设置执行testing的状态,但是每当执行代码时,都会使用这一行创build新的工作簿: wwbCopy = Workbook.createWorkbook(new File(testSuitePath)); 现在任何人都可以让我知道如何设置执行testing用例的状态。 为此,我正在使用JXL lib。 并在keydriven框架。 下面是在Excel中写入的代码: public class MainClass { private static final String BROWSER_PATH = "D:\\softs\\FF installed\\FF18\\firefox.exe"; private static final String TEST_SUITE_PATH = "D:\\GmailTestSuite.xls"; private static final String OBJECT_REPOSITORY_PATH = "D:\\objectrepository.xls"; private static final String ADDRESS_TO_TEST = "https://www.gmail.com"; private WebDriver driver; private Properties properties; public MainClass() { File file = […]

Selenium Java – 将hashmap值写入excel

我正在尝试使用hashmap值在excel文件中编写testing用例状态,但不是将数据写入excel。 这是我的代码 – public void readData() throws Exception { String filePath = System.getProperty("user.dir") + "\\Test Data"; String fileName = "editSubscriptions.xls"; String sheetName = "datapool"; File file = new File(filePath + "\\" + fileName); FileInputStream fis = new FileInputStream(file); Workbook workbook = null; String fileExtName = fileName.substring(fileName.indexOf(".")); if (fileExtName.equals(".xlsx")) { workbook = new XSSFWorkbook(fis); } else […]

尝试将结果写入excel时发生NullPointerException

有人可以帮助这个代码? 我收到有关NullPointerException在41行的错误消息。 我知道它返回null,但是这个值是以下validation所必需的。 一般的任务是将结果写入excel文件。 public class ExcelUtils { public static void main(String[] args) { //Blank workbook XSSFWorkbook workbook = new XSSFWorkbook(); //Create a blank sheet XSSFSheet sheet = workbook.createSheet("Employee Data"); String Result = "TEST TEST TEST"; int RowNum = 2; int ColNum = 3; XSSFSheet ExcelWSheet = sheet; XSSFCell Cell; XSSFRow Row; try { Row […]

如何使selenium等待页面完全加载到Excel VBA的包装?

Selenium的什么代码或函数 – 用于Excel VBA的包装器,以便程序等待页面完全加载然后执行其他命令?

打印简单值使用来自不同列的Excel,ArrayList和Java不起作用如果在具有值的数行之间不存在匹配

我想要做的只是打印多个值使用for循环和arraylist从多列与下面的代码 // =========The SpreadSheet========= File src = new File("J:\\Excel files\\mutiselect.xlsx"); // Load file FileInputStream fis = new FileInputStream(src); // Load WB XSSFWorkbook wb = new XSSFWorkbook(fis); // Load Sheet XSSFSheet sh1 = wb.getSheetAt(0); List<String> values = new ArrayList<String>(); //values from excel will be stored within this array Iterator<Row> rows = sh1.rowIterator(); while (rows.hasNext()) { Row […]

如何使用java在selenium中inputexcel文件的结果

我已经完成了从Excel中写入读取input数据的代码,现在我想在Excel中写入PASS,FAIL结果到特定的testing用例,但我不知道如何编写正确的代码。 所以你可以举个例子。 请帮帮我。 这是我的代码。 public static void main(String[] args) throws IOException { WebDriver driver=null; Scanner scanner = new Scanner(System.in); // prompt for the URL System.out.print("Enter your URL: "); // get their input as a String String URL = scanner.next(); //System.out.println( URL ); final FirefoxProfile firefoxProfile = new FirefoxProfile(); driver = new FirefoxDriver(firefoxProfile); driver.get(URL); driver.manage().timeouts().implicitlyWait(120, TimeUnit.SECONDS); […]

如何在java中使用selenium webdriver中的apache poi在excel文件中创build新工作表

我正在使用selenium webdriver – Java。 我需要将testing用例的结果写入excel文件,我使用了Apache POI.I成功地创build了一个excel文件,并将testing用例“Registration”的结果写入其中。 现在我想将testing用例“login”的结果写入同一个Excel文件中的另一个工作表。 我如何添加一个新的工作表到我的Excel文件,并在其中写入? 我会更清楚地解释。 我有3个类: QZO.java , QZO_Registration.java和QZO-Login.java 。 – QZO_Registration.java包含不同的注册testing用例。 – QZO_Login包含不同的Logintesting用例。 – QZO.java包含一些QZO_Registration和QZO_Login常用的函数。 – QZO.java包含用于在课堂上创build2张的代码 sheet1 = workbook.createSheet(“TestResult_Registration”); sheet2 = workbook.createSheet("TestResult_Registration"); 当我运行类QZO_Registration一个Excel文件创build2张TestResult_Registration和TestResult_Login。 注册testing用例的结果写在TestResult_Registration表单中。 但是,当我运行类QZO_Login,工作表TestResult_Registration中的值被清除 QZO_Registration.java package User; import java.io.IOException; import junit.framework.Assert; import jxl.read.biff.BiffException; import org.openqa.selenium.WebElement; import org.testng.annotations.AfterTest; import org.testng.annotations.BeforeTest; import org.testng.annotations.Test; @SuppressWarnings("deprecation") public class QZO_Registration extends QZO { […]