package webdriver3;
import java.util.Set;
import java.util.concurrent.TimeUnit;
import org.openqa.selenium.By;
import org.openqa.selenium.WebDriver;
import org.openqa.selenium.WebElement;
import org.openqa.selenium.firefox.FirefoxDriver;
import org.openqa.selenium.interactions.Actions;
import org.openqa.selenium.support.ui.ExpectedConditions;
import org.openqa.selenium.support.ui.WebDriverWait;
import org.testng.Reporter;
import org.testng.annotations.BeforeClass;
import org.testng.annotations.Parameters;
import org.testng.annotations.Test;
public class TestingAmazon {
WebDriver driver;
@BeforeClass
public void setUp(){
driver = new FirefoxDriver();
driver.get("http://google.co.in");
driver.manage().window().maximize();
openAmazon();
}
public void openAmazon(){
driver.findElement(By.xpath("//input[@id='lst-ib']")).sendKeys("Amazon india");
driver.findElement(By.xpath("//div[@id='sblsbb']/button")).click();
driver.manage().timeouts().implicitlyWait(2000, TimeUnit.SECONDS);
driver.findElement(By.xpath("//a[text()='Amazon']")).click();
hoverLogin();
}
public void hoverLogin(){
Actions builder=new Actions(driver);
WebElement mainmenu= driver.findElement(By.xpath("//a[@id='nav-link-yourAccount']/span[1]"));
builder.moveToElement(mainmenu).build().perform();
WebDriverWait wait = new WebDriverWait(driver, 5);
wait.until(ExpectedConditions.presenceOfElementLocated(By.xpath("//div[@id='nav-flyout-ya-signin']/a/span")));
WebElement submenu=driver.findElement(By.xpath("//div[@id='nav-flyout-ya-signin']/a/span"));
submenu.click();
Reporter.log("Done.....",true);
}
@Parameters({"userName","password"})
@Test
public void enterCreditial(String userName, String password){
driver.manage().timeouts().implicitlyWait(30, TimeUnit.SECONDS);
WebElement loginbox= driver.findElement(By.xpath("//input[@id='ap_email']"));
WebElement passwordbox= driver.findElement(By.xpath("//input[@id='ap_password']"));
WebElement signin= driver.findElement(By.xpath("//input[@id='signInSubmit']"));
if(loginbox.isDisplayed()){
Reporter.log("You can enter log in name");
loginbox.sendKeys(userName);
if(passwordbox.isDisplayed()){
Reporter.log("You can enter password");
passwordbox.sendKeys(password);
if(signin.isDisplayed()){
Reporter.log("You can signin");
signin.click();
}
}
}
}
public void informationCommand(){
String titletext=driver.getTitle();
System.out.println("Title is:" + titletext);
String pageurl= driver.getCurrentUrl();
System.out.println("Page url:" + pageurl);
String windowhandle= driver.getWindowHandle();
System.out.println("Windowhandle:" + windowhandle);
Set<String>windowhandles= driver.getWindowHandles();
System.out.println("Windowhandles:" + windowhandles);
}
public void signout(){
Actions builder=new Actions(driver);
WebElement mainmenu= driver.findElement(By.xpath("//a[@id='nav-link-yourAccount']/span[1]"));
builder.moveToElement(mainmenu).build().perform();
WebDriverWait wait=new WebDriverWait(driver,5);
wait.until(ExpectedConditions.presenceOfElementLocated(By.xpath("//a[@id='nav-item-signout']/span")));
WebElement signout=driver.findElement(By.xpath("//a[@id='nav-item-signout']/span"));
signout.click();
Reporter.log("Successfuly signout.......",true);
driver.quit();
}
}
使用TestNG脚本运行此程序时,出现以下错误:
参数'userName'是@Test on method entCredisive所必需的,但未在C:\用户\jahansalia\AppData\本地\Temp\testng-eclipse-1960767273中标记@可选或定义\testng-customsuite.xml
我看起来你没有用testng.xml
用于填充此方法参数的变量列表。这些变量必须在testng.xml文件中定义。举个例子
@Parameters({ "xmlPath" })
@Test
public void verifyXmlFile(String path) { ... }
在testng中。xml您需要提供如下详细信息:
<parameter name="xmlPath" value="account.xml" />
参考:-
http://www.tutorialspoint.com/testng/testng_parameterized_test.htm
LOGCAT错误阻止我打开MAP活动并停止工作。
本文向大家介绍运行jar程序时添加vm参数的方法,包括了运行jar程序时添加vm参数的方法的使用技巧和注意事项,需要的朋友参考一下 设置vm堆大小以及,配置远程监控参数 设置远程端口为8999,不需要用户名密码验证,初始化堆内存为64M、最大堆内存为128M、新生代为20M,Survivor区与Eden区内存为2:8 java -Djava.rmi.server.hostname=主机ip -Dc
错误如下: 02-11 13:24:31.561 526 2-5262/?E/AndroidRuntime:致命异常:main process:com.example.vicky.project,pid:5262 java.lang.runtimeException:无法启动活动ComponentInfo{com.example.vicky.project/com.example.vicky.pr
无效的DEP文件:C:\Users\bhard\AndroidStudioProjects\true\u weather。dart_工具\flatter_构建\54ec25ea3e00199f07d81cf92fc10210\kernel_快照。d无效的depfile:C:\Users\bhard\AndroidStudioProjects\true_weather。dart_工具\flatter