Tag: selenium

在阅读excel时使用apacahe poi获取未知字符

我正在使用一个使用Java和selenium开发的框架。 在使用apache poi从excel中读取值时,用空格replace未知字符。 有没有人遇到过这个问题? 如果请让我知道解决scheme。 提前致谢。

如何在Robot Framework的excel文件中创build和放置数据?

我想创build一个Excel文件,并使用Robot Framework将input数据添加到它。 所以我添加了Excel库。 这里是我使用的代码,我收到了一条错误消息 IndexError:列表索引超出范围 所以我评论了第三行,得到了列数和行数为0。 Create Excel Workbook NewExcelSheet Save Excel NewExcel.xls default=True Open Excel NewExcel.xls default=True Put Number To Cell NewExcelSheet 1 1 90 ${Col}= Get Column Count NewExcelSheet ${Row}= Get Row Count NewExcelSheet Log ${Col} Log ${Row} 为什么我将0作为列和行的值,为什么我不能在其中添加值?

VBA + Selenium不会返回objeck / element的大小

我有一个非常令人沮丧的selenium问题。 我正在使用VBA + Selenium,我试图检查一个元素是否存在。 我正在通过查找元素并检查它的大小来做到这一点。 如果它是0,则意味着它不存在。 我使用下面的代码: element_size = driver.FindElementByCss("div.toto > p:nth-child(6)").Size 我可能使用它是错误的,因为我得到一个“对象不支持这个属性”的错误。 但是,如果我使用: element_size = driver.FindElementByCss("div.toto > p:nth-child(6)").Text 然后我得到所需的文字。 那么我的尺寸代码有什么问题? (我也试过.size(),但我得到相同的错误) 感谢您的帮助提前,周末愉快!

无法在selenium webdriver中写入Excel表单

这是我用于将两个string写入Excel工作表的代码。 但我得到这个错误: java.lang.IllegalArgumentException: Sheet index (0) is out of range (no sheets) FileOutputStream fout=new FileOutputStream(new File("C:\\Users\\151680\\workspace\\trial.xlsx")); XSSFWorkbook wb=new XSSFWorkbook(); XSSFSheet sh1=wb.getSheetAt(0); sh1.getRow(0).createCell(0).setCellValue("abc"); sh1.getRow(0).createCell(1).setCellValue("def"); wb.write(fout); 目前在给定path中没有名为trial.xlsx的工作簿。 当这个代码运行它应该创build工作簿的权利? 或者我必须创build并保持path? 我在这里做错了什么?

断言try / catch块不能按预期工作

当我运行我的Selenium脚本时,我使用了sorta的断言方法。 当断言得到满足(元素存在)时,脚本写入一个xls文件。 当它不符合时,脚本不写入xls文件,它停止在那里的testing。 try { assertEquals(driver.findElement(By.xpath(prop.getProperty("failedlogin"))).getText(), "LOG IN"); //add pass entry to the excel sheet testresultdata.put("4", new Object[] { 3d, "User should not be able to login with no password", "Login failed", "Pass" }); } catch (Exception e) { //add fail entry to the excel sheet testresultdata.put("4", new Object[] { 3d, "User should not be […]

如何在Selenium中只跳过一种方法

在selenium中,作为使用testng的混合框架的一部分,如果在excel表中设置了“否”,那么应该跳过这个案例。 注意 :testing用例名称和方法名称也相同。 这里是这样的情况:我正在使用TestNG的BeforeMethod和Test注解。 而在Excel表格中,我有这样的 TCID Description Runmode TestCaseA1 vvvvvvvvvvvvvvvv N TestCaseA2 vvvvvvvvvvvvvvvv Y 由于第一种情况设置为“否”,即使将其设置为“是”,也会跳过下一个案例。 以下是代码。 请提供问题的解决scheme。 @BeforeMethod public void checkTestSkip(Method method) throws IOException{ intialise();//to load the properties String testName = method.getName(); if (!testUtil.isTestCaseRunnable(SuiteAXls,testName)) { App_Logs.info("Skipping the case as set to No"); throw new SkipException("Skipping the case as set to No"); } else { App_Logs.info("Not […]

使用Selenium RC,Excel(数据驱动)和SeleniumException

我现在正在开发一个自动化项目,在特定的网站上创build一个帐户。 有不同的规则需要检查。 需要有一组数据,其中缺less一些必填字段,用于在帐户上创build的电子邮件地址已经在系统上使用,最后一组是可以创build帐户的地方。 该过程的一般stream程是: 运行SeleniumRC 从ExcelFile获取数据 Excel数据由不同的集合组成。 设置A:缺less所需的Fille设置B:电子邮件地址已被使用设置B:完整/正确的数据 去网站。 input所有数据。 如果设置为A: Then creation will not process. It will provide output: Row Number – Error 如果设置B: Then creation will not process. It will provide output: Row Number – Error 如果设置C: It will create account. 提供屏幕截图盎司login 返回到步骤2,直到Excel文件中find的所有行都被完全检查。 输出将被放置在另一个Excel文件中 我能够运行的过程,但是,如果我在Excel文件中的每个条目使用一个标志。 这确实破坏了检查创build过程的预期目的。 我的selenium命令是这样的: public void test_CreateAccount() throws Exception { […]

保存从互联网的Excel文件

我正在尝试使用Selenium从站点下载Excel文件。 我这样做的方式: WebElement excelList = driver.findElement(By.xpath("…")); excelList.click(); driver.manage().timeouts().implicitlyWait(10, TimeUnit.SECONDS); String pageSource = driver.getPageSource(); FileOutputStream fos = new FileOutputStream("d:/load.xls"); for (int i = 0; i < pageSource.length(); i++) { char c = pageSource.charAt(i); fos.write((byte) c); } fos.close(); 页面源string长度等于我从这个站点手动下载的文件大小。 问题是我不正确地保存数据和MS Excel无法打开保存的文件。 如何正确保存文件?

用Selenium WebDriver C#和带有值的Web窗体读取Excel文件

我有一个用C#编写的Selenium WebDriver脚本,它从Excel电子表格中读取一些值,然后使用行中的值填充Web表单。 我现在面临的挑战是,它从Excel文件中获取第一个单元格值,并将其input到表单中的所有字段,然后获取下一个值并执行相同操作,依此类推。 我怎样才能使它取得第一个值,添加到窗体中的第一个(命名的字段),第二个值和第二个命名的字段等等。 请参阅下面的方法的代码。 public void FillForm() //Function reads entries from an Excel spreadsheet then uses values to populate and fill the form { Excel.Application xlApp; Excel.Workbook xlWorkBook; Excel.Worksheet xlWorkSheet; Excel.Range xlrange; string xlString; int xlRowCnt = 0; int xlColCnt = 0; xlApp = new Excel.Application(); //Open Excel file xlWorkBook = xlApp.Workbooks.Open(@"D:\Projects\Data\MSI_Data_file.xlsx", 0, true, […]

在Selenium Java中从Excel文件读取数据

我正在尝试从Excel工作表中读取数据以自动执行我的testing(使用许多login凭证)。 我正在使用我在网上find的实用程序。 但它没有成功运行。 这是实用程序 package google; import java.io.File; import java.io.IOException; import java.util.Hashtable; import jxl.Cell; import jxl.Sheet; import jxl.Workbook; import jxl.read.biff.BiffException; public class class2 { static Sheet wrksheet; static Workbook wrkbook =null; static Hashtable dict= new Hashtable(); //Create a Constructor public class2(String ExcelSheetPath) throws BiffException, IOException { //Initialize wrkbook = Workbook.getWorkbook(new File(ExcelSheetPath)); //For Demo purpose the […]