Tag: testng

Selenium web驱动程序:无法滚动到视图中

我在eclipse中使用Selenium IDE和Selenium web驱动程序testng我的测试是针对ZK应用程序的.. 测试用例在Selenium IDE上运行良好.. work it2 work it2 open /xxx click //li[2]/div/div/div/span pause 3000 3000 doubleClick //div[2]/div[2] pause 3000 3000 但是当我使用selenium web driver(testng)在eclipse中运行它时,我收到了一个错误.. selenium.open(“xxx”); selenium.click(“//li[2]/div/div/div/span”); Thread.sleep(3000); selenium.doubleClick(“//div[2]/div[2]”); Thread.sleep(3000); 我还将代码更改为 driver.get(“xxx”); driver.findElement(By.xpath(“//li[2]/div/div/div/span”)).click(); Thread.sleep(3000); WebElement ee = driver.findElement(By.xpath(“//div[2]/div[2]”)); Actions action = new Actions(driver); action.doubleClick(ee).perform(); Thread.sleep(3000); 也得到同样的错误…… 错误就在这一行 //div[2]/div[2] com.thoughtworks.selenium.SeleniumException:元素内的偏移量无法滚动到视图中:(87,118):[object XrayWrapper [object HTMLDivElement]]命令持续时间或超时:63毫秒构建信息:版本:’2.39.0’,修订版:’ff23eac’,时间:’2013-12-16 16:11:15’系统信息:主机:’EnD’,ip:’192.168.17.76’,os.name:’Windows 7’,os.arch:’ amd64’,os.version:’6.1’,java.version:’1.7.0_51’会话ID:3b79783c-2558-4c87-bd51-a72821696040驱动程序信息:org.openqa.selenium.firefox.FirefoxDriverfunction[{platform = […]

如果它是两个组的成员,是否可以为TestNG运行测试?

我知道你可以在你的xml中定义你想要运行的组,但我想知道如果它们都是组A和B的成员,是否可以说运行这些方法。 假设我有以下测试用例; @Test(groups={“A”,”B”}) public testA() {} @Test(groups={“B”,”C”}) public testB(){} 以及配置; 这将同时运行testA和testB,因为它们都是B组的成员。我想只在它是A组和B组的成员时才运行测试。 是否可以使用TestNG做这样的事情? 提前致谢

错误:org.testng.TestNGException:在类路径中找不到类:EmpClass

当我试图运行测试套件时,我得到了这个例外。 我们在这里使用maven项目,我完成了刷新,清理,重新安装testNG然后导入maven项目,但后来也得到了同样的例外。 请在此处提出任何遗漏方法。 错误控制台: org.testng.TestNGException: Cannot find class in classpath: EmpClass at org.testng.xml.XmlClass.loadClass(XmlClass.java:81) at org.testng.xml.XmlClass.init(XmlClass.java:73) at org.testng.xml.XmlClass.(XmlClass.java:59) at org.testng.xml.TestNGContentHandler.startElement(TestNGContentHandler.java:543) at com.sun.org.apache.xerces.internal.parsers.AbstractSAXParser.startElement(AbstractSAXParser.java:509) at com.sun.org.apache.xerces.internal.parsers.AbstractXMLDocumentParser.emptyElement(AbstractXMLDocumentParser.java:182) at com.sun.org.apache.xerces.internal.impl.dtd.XMLDTDValidator.emptyElement(XMLDTDValidator.java:766) at com.sun.org.apache.xerces.internal.impl.XMLDocumentFragmentScannerImpl.scanStartElement(XMLDocumentFragmentScannerImpl.java:1350) at com.sun.org.apache.xerces.internal.impl.XMLDocumentFragmentScannerImpl$FragmentContentDriver.next(XMLDocumentFragmentScannerImpl.java:2778) at com.sun.org.apache.xerces.internal.impl.XMLDocumentScannerImpl.next(XMLDocumentScannerImpl.java:606) at com.sun.org.apache.xerces.internal.impl.XMLDocumentFragmentScannerImpl.scanDocument(XMLDocumentFragmentScannerImpl.java:510) at com.sun.org.apache.xerces.internal.parsers.XML11Configuration.parse(XML11Configuration.java:848) at com.sun.org.apache.xerces.internal.parsers.XML11Configuration.parse(XML11Configuration.java:777) at com.sun.org.apache.xerces.internal.parsers.XMLParser.parse(XMLParser.java:141) at com.sun.org.apache.xerces.internal.parsers.AbstractSAXParser.parse(AbstractSAXParser.java:1213) at com.sun.org.apache.xerces.internal.jaxp.SAXParserImpl$JAXPSAXParser.parse(SAXParserImpl.java:649) at com.sun.org.apache.xerces.internal.jaxp.SAXParserImpl.parse(SAXParserImpl.java:333) at javax.xml.parsers.SAXParser.parse(SAXParser.java:195) at org.testng.xml.XMLParser.parse(XMLParser.java:39) at org.testng.xml.SuiteXmlParser.parse(SuiteXmlParser.java:17) at org.testng.xml.SuiteXmlParser.parse(SuiteXmlParser.java:10) at org.testng.xml.Parser.parse(Parser.java:168) […]

在TestNG上检索测试名称

我可以像在JUnit中一样检索当前运行的测试名称(使用getName()或规则 )吗? @Test public void fooBar(){ System.out.println(magic()); //should print “fooBar” } PS我不想使用一些基于堆栈跟踪的自编工具。

如何根据条件禁用TestNG测试

目前有一种方法可以根据条件禁用TestNG测试 我知道你当前可以在TestNG中禁用测试: @Test(enabled=false, group={“blah”}) public void testCurrency(){ … } 我想根据条件禁用相同的测试,但不知道如何。 像这样的东西: @Test(enabled={isUk() ? false : true), group={“blah”}) public void testCurrency(){ … } 任何人都知道这是否可行。

TestNG依赖来自不同类的OnMethods

当要依赖的测试与具有此批注的测试的类相同时,@ Test注释的dependsOnMethods属性可以正常工作。 但是如果要测试的方法和依赖方法在不同的类中,它就不起作用。 示例如下: class c1 { @Test public void verifyConfig() { //verify some test config parameters } } class c2 { @Test(dependsOnMethods={“c1.verifyConfig”}) public void dotest() { //Actual test } } 有没有办法解决这个限制? 一个简单的方法是在class c2中创建一个调用c1.verifyConfig() 。 但这将是太多的重复。

无法在Eclipse-Kepler中安装TestNG

当我尝试在我的VM(虚拟机)上安装TestNG时收到错误“无法在http://beust.com/eclipse/content.xml上读取存储库”。 “同行未经过身份validation” 我在网上尝试了很多解决方案,但没有运气。 任何人都可以帮我解决这个问题。 Eclipse版本:Kepler Service Release 1 Build id:20130919-0819 注意 :我没有VM上的Admin Privilege 谢谢,坎南

如何在网格上运行时关闭ChromeDriver?

我目前正在使用带有Selenium Grid 2的RemoteWebDriver通过TestNG套件运行我的测试。 这适用于Firefox和IE。 现在我添加了Chrome并且测试运行正常,但是在套件的所有测试之后调用driver.quit()时总是得到一个Exception(适用于FF和IE)。 Exception看起来像这样: Error communicating with the remote browser. It may have died. sun.reflect.NativeConstructorAccessorImpl.newInstance0(Native Method) at sun.reflect.NativeConstructorAccessorImpl.newInstance(NativeConstructorAccessorImpl.java:39) at sun.reflect.DelegatingConstructorAccessorImpl.newInstance(DelegatingConstructorAccessorImpl.java:27) at java.lang.reflect.Constructor.newInstance(Constructor.java:513) at org.openqa.selenium.remote.ErrorHandler.createThrowable(ErrorHandler.java:188) at org.openqa.selenium.remote.ErrorHandler.throwIfResponseFailed(ErrorHandler.java:145) at org.openqa.selenium.remote.RemoteWebDriver.execute(RemoteWebDriver.java:472) at org.openqa.selenium.remote.RemoteWebDriver.execute(RemoteWebDriver.java:476) at org.openqa.selenium.remote.RemoteWebDriver.quit(RemoteWebDriver.java:346) at setups.StandardChromeSetup.tearDown(StandardChromeSetup.java:42) 19 lines not shown Caused by Error communicating with the remote browser. It may have died. org.openqa.selenium.remote.RemoteWebDriver.execute(RemoteWebDriver.java:467) at org.openqa.selenium.remote.RemoteWebDriver.execute(RemoteWebDriver.java:476) […]

在Java中为什么会出现这个错误:’属性值必须是常量’?

我有一些TestNG代码,我传递一个名为timeOut = TESTNG_TEST_TIMEOUT的Test annotation参数。 @Test(description = “Tests something.”, groups = { “regression” }, timeOut = TESTNG_TEST_TIMEOUT, enabled = true) 在我的TestBase类中,我有这个成员: public final static long TESTNG_TEST_TIMEOUT = TimeUnit.MINUTES.toMillis(5); 当我使用上面的代码行时,我在Eclipse中得到一个’属性值必须是常量’错误。 但是,如果我只是这样定义成员,它的工作原理如下: public final static long TESTNG_TEST_TIMEOUT = 300000; TimeUnit的使用不是常数吗?

在测试方法中重新加载或刷新Spring应用程序上下文?

我需要在我的测试类的单个方法中更改我的applicationContext中活动的Spring配置文件,为此我需要在刷新竞赛之前运行一行代码,因为我使用的是ProfileResolver。 我尝试过以下方法: @WebAppConfiguration @ContextConfiguration(locations = {“/web/WEB-INF/spring.xml”}) @ActiveProfiles(resolver = BaseActiveProfilesResolverTest.class) public class ControllerTest extends AbstractTestNGSpringContextTests { @Test public void test() throws Exception { codeToSetActiveProfiles(…); ((ConfigurableApplicationContext)this.applicationContext).refresh(); … tests here … codeToSetActiveProfiles(… back to prior profiles …); … ideally refresh/reload the context for future tests } } 但我得到: java.lang.IllegalStateException: GenericApplicationContext does not support multiple refresh attempts: just call […]