Tag: testng

将testing时间追加到最终用户友好的.xls / .csv文件中

现在,我们成功/准确地报告testingID,说明,预期结果和通过/失败值。 我想添加运行testng.xml(执行和完成testing所需的时间)结束时可以看到的值,并将其附加到我的文件中。 有没有办法loggingTestNGtesting所花费的时间并将其输出到Excel / CSV中?

Selenium TestNG从Excel工作表中传入参数

我正在创build一个functiontesting,selenium将作为一个用户在网站上注册一个帐户,但是,网站注册有16个input字段来填写。一些Int值和一些string。 有没有更简单的方法来做到这一点? @Test(dataProvider = "Reg") public void login(String sUsername, String sPassword, String sMemorableWord) { 我只在那里传递3个值,但是完成了完整的注册testing,将会有16个string或Int参数。 这将是一个巨大的名单是否有另一种方式来做到这一点?

无法从xls获取testdata,而通过“可执行jar”文件运行seleniumtesting

我使用下面的代码创build可执行的jar文件来运行selenium脚本。 public class ExecutableRar { public static void main(String[] args) { TestListenerAdapter tla = new TestListenerAdapter(); TestNG testng = new TestNG(); List<String> testFilesList = new ArrayList<String>(); testFilesList.add("C:\\path to testng.xml file\\testng.xml"); testng.setTestSuites(testFilesList); testng.setUseDefaultListeners(false); testng.addListener(tla); testng.run(); } } 另外为了执行testing用例,我使用了testdata.xls。 每当我执行任何testing,testdata.xls是必需的。 以下是我的项目的层次结构:[请点击图片以取消]。 我已经从eclipse – > Project – > Export – >创build了可执行jar文件作为“Runnable jar文件”。 所以当我执行jar文件时,testing用例开始执行,但是找不到testdata.xls文件,所以脚本终止失败。 我的问题是: 我需要做什么更改,以便在使用jar文件执行testing时,我的脚本将从testingdata.xls中获取testing数据? 更新 : – […]

Selenium中的数据提供者与TestNG不匹配

我正在下面的代码写在selenium和下面的错误显示,请让我知道问题在哪里。 import org.testng.annotations.DataProvider; import org.testng.annotations.Test; public class testngexcel { public static ExcelReader excel = null; @Test(dataProvider = "newdata") public void testData(String username, String password, Integer age) { System.out.println(username + " – " + password + " – " + age); } @DataProvider(name = "newdata") public static Object[][] getData() { if (excel == null) { excel […]

如何根据内部逻辑多次运行testNGtesting?

我已经通过一些解决scheme来讲述TestNg DataProvider和InvocationCount ,但是DataProvider或InvocationCount甚至在我的@Test方法启动之前就已经出现了。 我的要求是,我有一个DataReader类,它以键值对的forms从Excel文件中读取数据(键总是在第一行,并且可以有多于一行的值)。 假设如果有2行的值可用,那么我将不得不与另一组数据运行相同的@Test (如果我可以为@Test的每次迭代运行@BeforeClass和@AfterClass方法将是很好的)。 像这样的东西: @BeforeClass //Some Code Here that runs on each iteration of @Test @Test public void myTest() { // make a decision here, based on number of rows of values, run the test multiple times DataReader.LoadDataSheet("TestData.xlsx", "SheetName"); } @AfterClass //Some Code Here that runs on each iteration of @Test

通过selenium可以进行Excel驱动的testing吗?

Sahi允许我将所需的functioninput电子表格,然后运行这些function。 不同的组合会导致不同的情况。我可以使用selenium做类似的事情吗? 我想通过excel文件select并调用testing/脚本/函数。 我正在使用testng框架从excel文件中获取数据。 谢谢

TestNG中的DataProvider使用Java WebDriver从Excel中传递数据

我有一个包含用户名和密码的login页面。 我有一个类XcelParserTestNGLogin来创build,更新和从Excel工作表加载方法。 还有另一个类是TestNG类的Login类。 我正在使用DataProvider从Excel传递数据。 但是我得到exception数据提供者正在尝试传递4个参数,但方法需要2 。 这是我的TestNG代码: public class Login { private static WebDriver driver; XcelParserTestNGLogin login1 = new XcelParserTestNGLogin(); Object[][] data1; /*public Login() throws IOException, InterruptedException { FileInputStream fis = new FileInputStream("Data//LoginPage.xls"); XcelParserTestNGLogin login1 = new XcelParserTestNGLogin(fis, "Login"); //this.data1 = login1.loadFromSpreadsheet(fis, "Login"); }*/ @BeforeClass public void test() throws Exception { System.setProperty("webdriver.chrome.driver", "C:\\Chrome\\chromedriver_win_26.0.1383.0\\chromedriver.exe"); driver = […]

用Selenium将testing结果写入Excel

我在这个问题上做了大量的研究,尝试了很多不同的方法,但是没有一个做我想做的,或者把它们应用到我自己的代码中的解释是非常模糊的。 我需要将testing结果(TestID,预期结果,通过或失败)导出到Excel表格中。 我目前使用TestNG和Apache POI。 我知道如何写一个excel表格,但是我绝对不知道如何写或不能通过或失败。 我目前正在使用一些不完全正常工作的代码 – 有时会写,有时候不会。 我需要最简单,最简单的方法来做到这一点,并有一个很好的解释。 我会告诉你我目前的@ @BeforeClass ,@ @AfterClass和两个@Test块。 @BeforeClass : @BeforeClass(alwaysRun = true) public void setupBeforeSuite(ITestContext context) throws IOException { //create a new work book workbook = new HSSFWorkbook(); //create a new work sheet sheet = workbook.createSheet("Test Result"); testresultdata = new LinkedHashMap < String, Object[] > (); //add test result […]

在我的TestNGtesting用例中解决NullPointerException

我试图通过使用TestNG从外部Excel表中使用多组login代码loginFacebook,但在代码之间我写了抛出: FAILED: f java.lang.NullPointerException at DataDriven.loginRetesting.f(loginRetesting.java:31) at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method) at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:57) at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43) at java.lang.reflect.Method.invoke(Method.java:601) at org.testng.internal.MethodInvocationHelper.invokeMethod(MethodInvocationHelper.java:84) at org.testng.internal.Invoker.invokeMethod(Invoker.java:714) at org.testng.internal.Invoker.invokeTestMethod(Invoker.java:901) at org.testng.internal.Invoker.invokeTestMethods(Invoker.java:1231) at org.testng.internal.TestMethodWorker.invokeTestMethods(TestMethodWorker.java:127) at org.testng.internal.TestMethodWorker.run(TestMethodWorker.java:111) at org.testng.TestRunner.privateRun(TestRunner.java:767) at org.testng.TestRunner.run(TestRunner.java:617) at org.testng.SuiteRunner.runTest(SuiteRunner.java:334) at org.testng.SuiteRunner.runSequentially(SuiteRunner.java:329) at org.testng.SuiteRunner.privateRun(SuiteRunner.java:291) at org.testng.SuiteRunner.run(SuiteRunner.java:240) at org.testng.SuiteRunnerWorker.runSuite(SuiteRunnerWorker.java:52) at org.testng.SuiteRunnerWorker.run(SuiteRunnerWorker.java:86) at org.testng.TestNG.runSuitesSequentially(TestNG.java:1224) at org.testng.TestNG.runSuitesLocally(TestNG.java:1149) at org.testng.TestNG.run(TestNG.java:1057) at org.testng.remote.RemoteTestNG.run(RemoteTestNG.java:111) at org.testng.remote.RemoteTestNG.initAndRun(RemoteTestNG.java:204) at org.testng.remote.RemoteTestNG.main(RemoteTestNG.java:175) […]

如何在Excel中使用Selenium WebDriver中的DataProvider读取Java和TestNG中的多组值

我对Selenium WebDriver相当陌生。 我写了代码来使用数据提供程序从Excel工作表中读取login凭据和值。 它通过第一个设置数据(loginfunction)完美地给我绿色状态栏。 在我的应用程序中,login后,我想通过发送索引和select(在pipe理方法)从同一Excel表中select值,但我没有读取值。 对于硬编码值,它的工作正常。 任何人都可以给我想法如何写它。 使用的Excel工作表: 以下是我的代码: import java.io.File; import jxl.Sheet; import jxl.Workbook; import org.testng.annotations.BeforeSuite; import org.testng.annotations.DataProvider; import org.testng.annotations.Test; import org.junit.AfterClass; import org.openqa.selenium.WebDriver; import org.openqa.selenium.firefox.FirefoxDriver; //import org.testng.annotations.BeforeClass; public class TestCase { String[][] tabArray = null; Workbook workbk; Sheet sheet; int rowCount, colCount; String sheetPath = "test/Resources/Data/Auto_Increment.xls"; WebDriver login; //int eRow, eCol, sRow = […]