- 獲得亞馬遜網址
- 登錄到亞馬遜
- 點擊您的帳戶
- 添加信用卡或借記卡元素
- 給予借記信息
- 保存。
任何人都可以解決,爲下面program.I我得到異常在主線程錯誤異常線程「main」顯示java.lang.NullPointerException硒
package amazon;
import static org.junit.Assert.*;
import java.sql.Driver;
import java.util.concurrent.TimeUnit;
import org.openqa.selenium.By;
import org.openqa.selenium.Proxy;
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.remote.CapabilityType;
import org.openqa.selenium.remote.DesiredCapabilities;
import org.openqa.selenium.support.ui.ExpectedConditions;
import org.openqa.selenium.support.ui.Select;
import org.openqa.selenium.support.ui.WebDriverWait;
public class Inheritancedemo
{
private WebDriver driver;
public void impexp(){
driver=new FirefoxDriver();
driver.manage().window().maximize();
driver.get("http://www.amazon.in/");
WebElement home=driver.findElement(By.id("nav-link-yourAccount"));
Actions builder=new Actions(driver);
builder.moveToElement(home).perform();
driver.findElement(By.xpath(".//*[@id='nav-flyout-ya-signin']/a/span")).click();
driver.manage().timeouts().implicitlyWait(10, TimeUnit.SECONDS);
driver.findElement(By.id("ap_email")).sendKeys("[email protected]");
driver.findElement(By.id("ap_password")).sendKeys("9952709603");
driver.findElement(By.id("signInSubmit")).click();
}
public void logusername()
{
WebElement home1=driver.findElement(By.xpath(".//*[@id='nav-link-yourAccount']/span[2]"));
Actions builder=new Actions(driver);
builder.moveToElement(home1).perform();
driver.findElement(By.xpath(".//*[@id='nav-flyout-yourAccount']/div[2]/a[1]/span")).click();
}
public void vardeclare()
{
WebElement home2=driver.findElement(By.xpath(".//*[@id='nav-link-yourAccount']/span[2]"));
Actions builder3=new Actions(driver);
builder3.moveToElement(home2).perform();
driver.findElement(By.xpath(".//*[@id='nav-item-signout']/span")).click();
}
}
package amazon;
import org.openqa.selenium.By;
import org.openqa.selenium.WebDriver;
import org.openqa.selenium.support.ui.Select;
public class Editpage extends Inheritancedemo{
public WebDriver driver;
public void edit()
{
driver.findElement(By.xpath(".//*[@id='a-page']/div[1]/div/div[3]/div/div/div[2]/div/div[1]/ul/li[2]/span/a")).click();
Select se=new Select(driver.findElement(By.id("creditCardIssuer")));
se.selectByIndex(1);
driver.findElement(By.id("addCreditCardNumber")).sendKeys("4596010006236333");
driver.findElement(By.id("card-name")).sendKeys("SURESH KUMAR");
Select se1=new Select(driver.findElement(By.id("newCreditCardMonth")));
se1.selectByIndex(4);
Select se2=new Select(driver.findElement(By.id("newCreditCardYear")));
se2.selectByIndex(5);
driver.findElement(By.id("enterAddressFullName")).sendKeys("SURESH KUMAR");
driver.findElement(By.id("enterAddressAddressLine1")).sendKeys("ALAGAR APARTMENTS");
driver.findElement(By.id("enterAddressAddressLine2")).sendKeys("GANDHIJI ST, SINGANALLUR");
driver.findElement(By.id("enterAddressCity")).sendKeys("COIMBATORE");
driver.findElement(By.id("enterAddressStateOrRegion")).sendKeys("KERALA");
driver.findElement(By.id("enterAddressPostalCode")).sendKeys("621405");
Select se3=new Select(driver.findElement(By.id("enterAddressCountryCode")));
se3.selectByIndex(4);
driver.findElement(By.id("enterAddressPhoneNumber")).sendKeys("7373875253");
driver.findElement(By.xpath(".//*[@id='newCreditCardForm']/table[3]/tbody/tr/td/table/tbody/tr/td/table/tbody/tr/td/table/tbody/tr[6]/td[2]/input"));
}
public static void main(String[] args) {
Editpage e=new Editpage();
e.impexp();
e.logusername();
e.edit();
e.vardeclare();
}
}
請顯示您的堆棧跟蹤 –