我的执行过程中有两个不一致之处。
1)在以下情况下,“并单击创建客户”注释无法正常工作。我已经更新过它,而不是包括“ @Then(“ Musteri Olustur tabina tikla ve acilan sayfada Submit butonuna tikla”)“在内的表达式,一旦我尝试通过右键单击功能文件执行运行来执行它,仍然会收到有关先前注释(以@Then开头的注释)的错误。
2)第二个问题是方案的第六步根本没有执行。 (“然后输入客户信息”)
这怎么可能?
前四个步骤正常运行。
Feature: Create Customer
Scenario: Create Prepaid Customer Turkish Citizen
Given Access to LegacyCRM
When Type your username and password
And Click login button
Then Verify that legacycrm is opened
And Click Create Customer
Then Type customer information
-
public class CucumberCustomer {
WebDriver driver;
@Given("^Access to LegacyCRM$")
public void AccessLCRM (){
File file = new File("C:/Users/wiprofkaymaz/Desktop/ie32/IEDriverServer.exe");
System.setProperty("webdriver.ie.driver",file.getAbsolutePath());
driver = new InternetExplorerDriver();
driver.get("https://iccbcf/TelsimGlobal/Menu/showLogin.jsp");
}
@When("^Type your username and password$")
public void TypingLoginInformations(){
driver.findElement(By.xpath("//input[@name='username']")).sendKeys("wiprobaslan");
driver.findElement(By.xpath("//input[@type='password']")).sendKeys("Voda123456789**");
}
@And("^Click login button$")
public void ClickLoginButton(){
WebElement login=driver.findElement(By.xpath("//input[@src='/TelsimGlobal/Menu/image3.gif']"));
login.click();
}
@Then("^Verify that legacycrm is opened$")
public void legacycrmverification(){
driver.switchTo().frame("ax");
driver.switchTo().frame("menu");
boolean vry =driver.findElement(By.xpath("//img[@src='images/vodafone_logo_top.gif']")).isDisplayed();
if(vry){
System.out.println("application has been opened");
}
else{
System.out.println("something wrong");
}
}
@And("^Click Create Customer$")
public void Customercreatev1(){
driver.findElement(By.xpath("//a[@title='Müşteri Oluşturma']")).click();
driver.switchTo().defaultContent();
driver.switchTo().frame("cx");
driver.findElement(By.xpath("//input[@name='Submit']")).click();
}
@Then("^Type customer information$")
public void Customercreatev2() throws InterruptedException{
driver.switchTo().defaultContent();
driver.switchTo().frame("cx");
driver.findElement(By.xpath("//input[@name='name']")).sendKeys("KEM");
driver.findElement(By.xpath("//input[@name='lastname']")).sendKeys("KEM");
Select selectObject = new Select (driver.findElement(By.xpath("//select[@name='day']")));
selectObject.selectByValue("10");
Thread.sleep(1000);
Select selectObject2 = new Select (driver.findElement(By.xpath("//select[@name='month']")));
selectObject2.selectByValue("10");
Thread.sleep(1000);
Select selectObject3 = new Select (driver.findElement(By.xpath("//select[@name='year']")));
selectObject3.selectByValue("1950");
Thread.sleep(1000);
String mainWindow = driver.getWindowHandle();
driver.findElement(By.xpath("//input[@name='iddistrict']")).sendKeys("ADANA");
driver.findElement(By.xpath("//input[@name='fathername']")).sendKeys("BABA");
driver.findElement(By.xpath("//input[@name='Submit']")).click();
Windows(driver, mainWindow);
driver.switchTo().window(mainWindow);
}
public void Windows (WebDriver driver, String mainWindow) {
mainWindow = driver.getWindowHandle();
Set<String> totalwindowsIds = driver.getWindowHandles();
int a=0;
String[] myset = totalwindowsIds.toArray(new String[totalwindowsIds.size()]);
if(myset[a].contains(mainWindow)){
driver.switchTo().window(myset[a+1]);
}
else{
driver.switchTo().window(myset[a]);
}
}
}