Skip to content
Advertisement

i’m tring to automate target.com in selenium using java

enter image description here 1.error in line 3 i can’t access registration btn (I tried using by id ,XPath,name and selector but dont work! )

@Test
public void registration() throws InterruptedException {
    mydriver.findElement(By.xpath("/html/body/div[1]/div/div[3]/div[2]/nav/a[7]/span[4]")).click(); // pass
    Thread.sleep(2000);// just for test
    mydriver.findElement(By.id("accountNav-signIn")).click(); // fail

    // mydriver.findElement(By.name("usernamecreateaccount")).sendKeys("test@gmail.com");
    // mydriver.findElement(By.name("firstnamecreateaccount")).sendKeys("mohammed");
    // mydriver.findElement(By.name("lastnamecreateaccount")).sendKeys("mobark");
    // mydriver.findElement(By.name("passwordcreateaccount")).sendKeys("Pass@1234");
    // WebElement submit_btn  =  mydriver.findElement(By.xpath("//*[@id="createAccount"]"));
}

Advertisement

Answer

Type about:profiles in the URL bar of firefox and check if the default profile exists at the location, If it doesn’t exist just create the one and provide the default or desired location.

Click on Create a new profile -> Continue –> Enter the profile name -> click Done

Try to access the profile created with the below lines of code

    ProfilesIni profile = new ProfilesIni();
    FirefoxProfile ffProfile = profile.getProfile("ffProfile");
    
    FirefoxOptions option = new FirefoxOptions();
    option.setProfile(ffProfile);
            
    WebDriver driver = new FirefoxDriver(option);
            
    driver.get("https://www.target.com");
User contributions licensed under: CC BY-SA
2 People found this is helpful
Advertisement