我正在使用任务从ant运行testng.我真的想在分叉的jvm中添加-server选项以及指定堆空间量.谁知道怎么做?
我在这里看不到任何内容:http: //testng.org/doc/ant.html
谢谢,本
我想知道我的代码有什么问题,因为当我尝试测试我的代码时,我什么也得不到.
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)
}
我正在使用 …
我有一个返回一些值的 DAO,如何检查方法是否抛出特定异常?
我正在使用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) 错误:
失败: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) 我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方法?
如何为这段代码编写单元测试
if (!isVisible()) {
throw new IllegalStateException("Not in xyz page");
}
return this.isAttached(DOT_ID);
Run Code Online (Sandbox Code Playgroud)
如果isVisible()被模拟返回false那么如何编写异常语句的单元测试
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标识符
我该如何解决?
我正在使用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) testng ×10
java ×9
selenium ×3
testing ×2
unit-testing ×2
annotations ×1
ant ×1
eclipse ×1
exception ×1
findby ×1
font-family ×1
hibernate ×1
java-12 ×1
qa ×1
xml ×1
xml-parsing ×1