标签: testng

来自ant的testng:指定-server -Xms?

我正在使用任务从ant运行testng.我真的想在分叉的jvm中添加-server选项以及指定堆空间量.谁知道怎么做?

我在这里看不到任何内容:http: //testng.org/doc/ant.html

谢谢,本

java ant testng unit-testing

0
推荐指数
1
解决办法
2007
查看次数

如何在Selenium WebDriver中使用@FindBy注释

我想知道我的代码有什么问题,因为当我尝试测试我的代码时,我什么也得不到.

public class SeleniumTest {

private WebDriver driver;
private String nome;
private String idade;

@FindBy(id = "j_idt5:nome")
private WebElement inputNome;

@FindBy(id = "j_idt5:idade")
private WebElement inputIdade;

@BeforeClass
public void criarDriver() throws InterruptedException {

    driver = new FirefoxDriver();
    driver.get("http://localhost:8080/SeleniumWeb/index.xhtml");
    PageFactory.initElements(driver, this);

}

@Test(priority = 0)
public void digitarTexto() {

    inputNome.sendKeys("Diego");
    inputIdade.sendKeys("29");

}

@Test(priority = 1)
public void verificaPreenchimento() {

    nome = inputNome.getAttribute("value");
    assertTrue(nome.length() > 0);

    idade = inputIdade.getAttribute("value");
    assertTrue(idade.length() > 0);
}

@AfterClass
public void fecharDriver() {

    driver.close();

}
Run Code Online (Sandbox Code Playgroud)

}

我正在使用 …

java testng annotations findby selenium-webdriver

0
推荐指数
1
解决办法
4万
查看次数

如何使用TestNG编写集成测试来检查JAVA中是否抛出异常?

我有一个返回一些值的 DAO,如何检查方法是否抛出特定异常?

java testng hibernate postgresql-9.1

0
推荐指数
1
解决办法
5425
查看次数

Selenium Webdriver和TestNG

我正在使用TESTNG在webdriver上运行代码......第一个测试完全正常但在我尝试执行test2之后... driver.findelement以红色加下划线并且根本不执行.以前的driver.findelement是棕色的,但是在test2是蓝色之后,为什么它不起作用的任何原因?

@Test(priority=1)
public void launchSandBoxTestingTestNG() throws InterruptedException{

    // Import FireFox Driver
    WebDriver driver = new FirefoxDriver();


    // Open up Sandbox Page
    driver.get("****");

    // Enter Usename and Password

    // User
    driver.findElement(By.id("userId")).sendKeys("****");
    Thread.sleep(3000);

    // Password
    driver.findElement(By.id("password")).sendKeys("****");
    Thread.sleep(3000);

    // Click Login Button
    driver.findElement(By.id("loginButton")).click();
}

@Test(priority=2)
public void test2(){
    driver.findElement(By.xpath("****")).click();
    // When I try running this code above it underlines the find element in red 
   // When I run it on web driver the test2 syntax doesnt work
   //It gives me an …
Run Code Online (Sandbox Code Playgroud)

java testng qa selenium-webdriver

0
推荐指数
1
解决办法
142
查看次数

我正在尝试从excel工作表中获取数据,并将这些测试数据传递到登录名和密码字段中,但出现以下错误

错误:

失败:cptoadsLogin org.testng.TestNGException:数据提供程序试图传递2个参数,但是com.toads.Script.LoginDemo#cptoadsLogin方法在org.testng.internal.Invoker.injectParameters(Invoker.java:1225)处采用0 org.testng.internal.TestMethodWorker.invokeTestMethods(TestMethodWorker.java:125)上的org.testng.internal.Invoker.invokeTestMethods(Invoker.java:1118)org.testng.internal.TestMethodWorker.run(TestMethodWorker.java:108)在org.testng的org.testng.SuiteRunner.runTest(SuiteRunner.java:359)的org.testng.TestRunner.run(TestRunner.java:624)的org.testng.TestRunner.privateRun(TestRunner.java:774)处。 org.testng.SuiteRunner.privateRun(SuiteRunner。)上的SuiteRunner.runSequentially(SuiteRunner.java:354)org.testng.SuiteRunner.run(SuiteRunner.java:261)处的org.testng.SuiteRunnerWorker.runSuite(SuiteRunnerWorker.java:52)处的org.testng.SuiteRunnerWorker.run(SuiteRunnerWorker.java:86)处的java:312) org.testng.TestNG.run(TestNG.java:1048)在org.testng.TestNG.runSuitesLocally(TestNG.java:1140)在org.testng.TestNG.run(TestNG.java:1048)在org.testng.remote org.testng.remote.RemoteTestNG.initAndRun(RemoteTestNG.java:236)的org.testng.remote.RemoteTestNG.main(RemoteTestNG.java:81)的.AbstractRemoteTestNG.run(AbstractRemoteTestNG.java:132)在org.testng.TestNG.runSuitesSequentially(TestNG.java:1215)在org.testng.TestNG.runSuitesLocally(TestNG.java:1140)在org.testng.TestNG.run(TestNG)的SuiteRunnerWorker.run(SuiteRunnerWorker.java:86) .java:1048),位于org.testng.remote.AbstractRemoteTestNG.run(AbstractRemoteTestNG.java:132),位于org.testng.remote.RemoteTestNG.initAndRun(RemoteTestNG.java:236),位于org.testng.remote.RemoteTestNG.main( RemoteTestNG.java:81)在org.testng.TestNG.runSuitesSequentially(TestNG.java:1215)在org.testng.TestNG.runSuitesLocally(TestNG.java:1140)在org.testng.TestNG.run(TestNG)的SuiteRunnerWorker.run(SuiteRunnerWorker.java:86) .java:1048),位于org.testng.remote.AbstractRemoteTestNG.run(AbstractRemoteTestNG.java:132),位于org.testng.remote.RemoteTestNG.initAndRun(RemoteTestNG.java:236),位于org.testng.remote.RemoteTestNG.main( RemoteTestNG.java:81)org.testng.remote.RemoteTestNG.main上的initAndRun(RemoteTestNG.java:236)(RemoteTestNG.java:81)org.testng.remote.RemoteTestNG.main上的initAndRun(RemoteTestNG.java:236)(RemoteTestNG.java:81)

页面对象:

import org.openqa.selenium.WebDriver;
import org.openqa.selenium.WebElement;
import org.openqa.selenium.support.FindBy;
import org.openqa.selenium.support.How;
import org.openqa.selenium.support.PageFactory;

public class ToadsLogin {

    @FindBy(how=How.XPATH,using="//input[@id='Username']")
    WebElement username;

    @FindBy(how=How.XPATH,using="//input[@id='Password']")
    WebElement password;

    @FindBy(how=How.XPATH,using="//button")
    WebElement loginbtn;

    public ToadsLogin(WebDriver driver)
    {
        PageFactory.initElements(driver, this);
    }

    public void unpwd(String un,String pwd)
    {
        username.sendKeys("un");
        password.sendKeys("pwd");
    }

    public void clikonLogin()
    {
        loginbtn.click();
    }
}
Run Code Online (Sandbox Code Playgroud)

TestNG脚本:

import org.testng.annotations.DataProvider;
import org.testng.annotations.Test;

import com.toads.PoM.ToadsLogin;
import com.toads.lib.ExcelDataConfig;

public class LoginDemo extends SuperTestNG {

    @Test(dataProvider="toadsLogin")
    public void cptoadsLogin() throws Exception
    { …
Run Code Online (Sandbox Code Playgroud)

java testng selenium data-driven-tests selenium-webdriver

0
推荐指数
1
解决办法
683
查看次数

在每次测试之前运行方法

testng 6.11在以下测试类中使用和编写测试:

public class MyTest{

    public int i;

    public void init(){
        //initialize i
    }

    @Test
    public void test1(){
        //test some
    }

    @Test
    public void test2(){
        //Here I need fresh value of i as it would be
        //right after invocation of init()
        //...
        //test something else
    }
}
Run Code Online (Sandbox Code Playgroud)

是否可以init()在调用测试类中的每个测试之前使 testng run方法?

java testing testng

0
推荐指数
1
解决办法
4218
查看次数

覆盖java单元测试中的异常语句

如何为这段代码编写单元测试

   if (!isVisible()) {
       throw new IllegalStateException("Not in xyz page");
   }
   return this.isAttached(DOT_ID);
Run Code Online (Sandbox Code Playgroud)

如果isVisible()被模拟返回false那么如何编写异常语句的单元测试

java testing testng unit-testing exception

0
推荐指数
1
解决办法
31
查看次数

从 testNG.xml 文件中检索参数值

在此处输入图片说明

我想从关键参数名称 ="webdriver.deviceName.iPhone"打印值"iPhone5 "

java xml testng xml-parsing

0
推荐指数
1
解决办法
5221
查看次数

在启动层 java.lang.module.FindException 初始化期间发生错误,使用 TestNG 和 Java 12 通过 Eclipse 执行 Selenium 测试

ErrorOccuredDuringInitializationofbootlayer我在运行测试时不断收到此错误:

启动层初始化时出错 java.lang.module.FindException:无法为 C:\Users\Bonfire.eclipse\org.eclipse.platform_4.12.0_867647348_win32_win32_x86_64\plugins\com.beust.jcommander_1.72.0.jar 派生模块描述符引起:java.lang.IllegalArgumentException:com.beust.jcommander.1.72.0:无效的模块名称:'1'不是Java标识符

我该如何解决?

eclipse testng selenium testng-eclipse java-12

0
推荐指数
2
解决办法
6411
查看次数

当我们使用 WebElement 的 obj 方法 .getCssValue("font-family") 时,TestNG 的 SoftAsert.assertEquals(actual,expected) 方法无法正常运行

我正在使用Selenium-server-standalone-3.141.59.jar文件和testNG 版本 6.14.3。使用它,我想比较 Web Element font-family 作为输入硬编码值,并使用 selenium driver.findElement从网站获取。现在我已经制作了方法SoftAssert代码

这是我尝试过的SoftAssert。创建方法并作为参数传递WebElement obj, fontNameValid作为值ProximaNova。现在我从HTML得到font-family是 ' ProximaNova-Light ' 理想情况下一旦我们添加assertEqual方法,SoftAssert 应该将此检测为错误,但它会通过测试用例。请帮忙。

CheckCSS.java

public static SoftAssert webElement_Check_CSS(WebElement obj, String fontNameValid) {

 String fontName1 = obj.getCssValue("font-family");
        System.out.println("Font Name from HTML :------->" + fontName1);
        System.out.println("Font Name as input :------->" + fontNameValid);

        softAssert.assertEquals(fontNameValid, fontName1,"WebElement is ["+obj.getText()+"] and Font name is not as per …
Run Code Online (Sandbox Code Playgroud)

java testng selenium font-family

0
推荐指数
1
解决办法
64
查看次数