0
  1. getting the amazon url
  2. login into to amazon
  3. clicking the your account
  4. add the credit or debit card element
  5. give the information of the debit
  6. save it.

Can anybody solve and explain for the below program.I am getting exception in main thread error

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("jothimani.naveen@gmail.com");
        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();
}   

}
James Z
  • 12,209
  • 10
  • 24
  • 44

1 Answers1

0

Naveen, start with below changes -Try declaring the web driver within the constructor of the Inheritance demo class with access modifier as public. -Do not declare the web driver again in the child class i.e. edit page class since driver declaration is handled by the super class.

prithvi394
  • 221
  • 1
  • 6