Currently automating a SnapDeal eCommerce website
A challenge I am facing is an error message in the console:
The issue occurs when transitioning from a child window back to the parent window and performing operations on the parent window.
//Automating the login process on SnapDeal using Facebook.
SnapDeal.findElement(By.xpath("//div[@id='fbUserLogin']")).click();
String pWindow = SnapDeal.getWindowHandle();
for (String winHandle : SnapDeal.getWindowHandles())
{
//Switching to the child window
SnapDeal.switchTo().window(winHandle);
}
WebElement FBLoginID = SnapDeal.findElement(By.xpath("//input[@id='email']"));
JavascriptExecutor js = (JavascriptExecutor)SnapDeal;
js.executeScript("arguments[0].value='YourEmailID';", FBLoginID);
WebElement FBPass = SnapDeal.findElement(By.xpath("//input[@id='pass']"));
JavascriptExecutor jE = (JavascriptExecutor)SnapDeal;
jE.executeScript("arguments[0].value='YourPassword';", FBPass);
SnapDeal.findElement(By.xpath("//button[@id='loginbutton']")).click();
SnapDeal.findElement(By.xpath("//button[@name='__CONFIRM__']")).click();
Thread.sleep(5000);
//Returning to the parent window
SnapDeal.switchTo().window(pWindow);
//Logging out of the application on the parent window after returning
WebElement WelCome = SnapDeal.findElement(By.xpath("//span[contains(.,'Welcome')]"));
WebElement LogOut = SnapDeal.findElement(By.xpath("//a[contains(.,'Logout')]"));
Actions mousehover = new Actions(SnapDeal);
mousehover.moveToElement(WelCome).perform();
Thread.sleep(5000);
mousehover.click(LogOut).perform();
If you have any insights on how to address this problem, please let me know. Thank you.