Tag: testng

如何使用Java在Selenium2(Webdriver)中键入Gmail正文文本

我尝试自动从Gmail发送电子邮件(https://accounts.google.com/ServiceLogin?service=mail&passive=true&rm=false&continue=http://mail.google.com/mail/&scc=1&ltmpl=default&ltmplcache=2)使用Selenium WebDriver和Java。 首先,我尝试使用Selenium IDE记录测试。 IDE无法记录电子邮件正文。 我尝试通过以下方式键入正文,但不幸的是它失败了。 driver.findElement(By.xpath(“// textarea [@ name =’body’]”))。sendKeys(“body text”); 错误是:FAILED:testSendingEmail org.openqa.selenium.ElementNotVisibleException:元素当前不可见,因此可能无法与命令持续时间或超时交互:30.02秒 有人可以帮帮我吗?

Java – 以编程方式关闭TestNG的默认记者

我有一个应用程序,我需要从我的main方法执行我的TestNG @Test注释方法,并使用ReportNG生成报告。 我的主要方法如下: public static void main(String args[]) { TestNG myTestNG = new TestNG(); XmlSuite mySuite = new XmlSuite(); mySuite.setName(“Sample Suite”); mySuite.addListener(“org.uncommons.reportng.HTMLReporter”); mySuite.addListener(“org.uncommons.reportng.JUnitXMLReporter”); XmlTest myTest = new XmlTest(mySuite); myTest.setName(“Sample Test”); List myClasses = new ArrayList(); myClasses.add(new XmlClass(“com.varunmulloli.testng.SampleTest”)); myTest.setXmlClasses(myClasses); List myTests = new ArrayList(); myTests.add(myTest); mySuite.setTests(myTests); List mySuites = new ArrayList(); mySuites.add(mySuite); myTestNG.setXmlSuites(mySuites); myTestNG.run(); } 我的SampleTest类看起来像这样: […]

多次运行TestNg套件

我说过N个测试类,我有一个测试套件说test.xml可以运行所有N个测试,如何运行多次测试套件的tests.xml? 请帮我解释如何以编程方式多次运行它

如何在testNG报告中包含故障屏幕截图

目前我以这种方式截取我的测试失败的截图: @AfterMethod(alwaysRun=true) public void catchExceptions(ITestResult result){ Calendar calendar = Calendar.getInstance(); SimpleDateFormat formater = new SimpleDateFormat(“dd_MM_yyyy_hh_mm_ss”); String methodName = result.getName(); if(!result.isSuccess()){ File scrFile = ((TakesScreenshot)driver).getScreenshotAs(OutputType.FILE); try { FileUtils.copyFile(scrFile, new File((String) PathConverter.convert(“failure_screenshots/”+methodName+”_”+formater.format(calendar.getTime())+”.png”))); } catch (IOException e1) { e1.printStackTrace(); } } } 我可以将自己的屏幕截图添加到TestNG报告链接或图片中吗? 如果有,怎么样? 我在网上找到的只是FEST框架。 但由于我已经截取屏幕截图,我不想使用另一个框架。

将变量从jenkins传递给testng.xml

我想根据从jenkins传递的变量运行测试用例,例如,选择要运行的测试用例:testcaseOne,testcaseTwo 在pom.xml(maven)中: org.apache.maven.plugins maven-surefire-plugin 2.18.1 testng.xml ${chooseCase} <–this dont work tests 10 我有两个testng @test方法: @Test(groups=”caseOne”) @Test(groups=”caseTwo”) 我的testng.xml文件: 如何传递此参数取决于我想要运行的测试数量和数量? 也许有完全不同的方式来做到这一点?

在集成测试不起作用之前启动apache服务器

我有一个名为GroupWebApplication的Web应用程序。 使用pom.xml文件我只是创建我的应用程序的战争并部署到tomcat服务器。 这基本上是一个maven项目。 我已经为tomcat7 apache服务器添加了插件。 现在我想要启动tomcat服务器,然后运行集成测试,在集成测试完成后,我想停止服务器。 基本上我正在使用TestNg的testng.xml文件framework.testng.xml文件包含集成测试的所有类。 手动它工作正常,即手动启动服务器并运行测试。 这是pom文件: org.testng testng 6.3.1 test sGroupWebApplication Integration Test src/main/resources org.apache.maven.plugins maven-dependency-plugin 2.4 resource-dependencies initialize unpack-dependencies com.company.integration.test engine **\/*.xpi,**\/*.exe,**\/*.so, **\/*.ftl,**\/*.css,**\/*.woff, **\/*.properties,**\/*.png,**\/chromedriver,**\/*.MF ${project.build.directory}/classes org.apache.tomcat.maven tomcat7-maven-plugin 2.0 http://localhost:8080/manager/text localhost /GroupWebApplication admin s3cret tomcat7-run run-war-only pre-integration-test true tomcat7-shutdown shutdown post-integration-test org.apache.maven.plugins maven-release-plugin 2.4.2 org.apache.maven.plugins maven-compiler-plugin 3.1 ${target.jdk} ${target.jdk} org.apache.maven.plugins maven-jar-plugin 2.4 […]

如何运行TestNG测试指向一个jar

我有一个.Jar文件,其中包含在TestNG test上运行所需的文件。我想在该Jar文件中运行一个特定的xml文件。我的要求是可以执行指向.Jar文件的TestNG测试,如果是这样的话我怎样才能做到这一点。

如何以编程方式使用TestNG运行Selenium Java测试?

我使用Selenium RC和Java一起使用TestNG作为测试框架。 我正在使用Eclipse作为IDE。 我想非常轻松地从我自己的程序中调用TestNG。 我怎样才能做到这一点?

Eclipse – Testng引用不存在的项目XXX,启动配置

当尝试将测试作为TestNG套件运行时,我会收到一条非常神秘的错误消息,指出TestNG无法启动,因为它引用了一个不存在的项目。 我认为我的项目确实存在,我在包浏览器中看到它!

TestNG中DataProvider和Factory之间有什么区别?

何时使用DataProvider以及何时使用Factory?