-1

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\"]"));
}
M.Mobark
  • 59
  • 4

2 Answers2

0

The menu appears only when hovering over sign in element.
Try hovering and clicking on the sign-in menu and then moving to sign-in li and clicking it with Actions.
Like this:

Actions action = new Actions(mydriver);
WebElement webElement = mydriver.findElement(By.xpath("//nav[@id='headerMain']//a[@id='account']"));
WebElement webElement1 = mydriver.findElement(By.xpath("//li[@id='accountNav-signIn']"));
action.moveToElement(webElement).click(webElement).moveToElement(webElement1).click(webElement1).build().perform();

UPD
As about

Can't find profile directory. console.warn: SearchSettings: "get: No settings file exists, new profile?

error see this and other answers here
First of all validate your browser profile as mentioned there.

Prophet
  • 32,350
  • 22
  • 54
  • 79
  • `The menu appears only when hovering over sign in element.` - without HTML or Page URL how did you get to know it's an hovering issue – cruisepandey Jul 11 '21 at 19:43
  • 1
    He mentioned he is trying to automate target.com – Prophet Jul 11 '21 at 19:45
  • 1
    the same error `JavaScript error: resource://gre/modules/XULStore.jsm, line 66: Error: Can't find profile directory. console.warn: SearchSettings: "get: No settings file exists, new profile?` – M.Mobark Jul 11 '21 at 19:47
  • @M.Mobark you did not mention this error before. I'll try to see what is it caused by. – Prophet Jul 11 '21 at 19:49
  • 1
    @Prophet : okay I didn't read the heading. – cruisepandey Jul 11 '21 at 19:51
  • @M.Mobark see updated answer. Looks like your problem is much before any actual code flow line as I referenced you – Prophet Jul 11 '21 at 19:55
0

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");
YaDav MaNish
  • 1,260
  • 2
  • 12
  • 20