You can easily get code for Frame switch. Please search for the question before posting it.
//Switch to Iframe
WebElement iframe = driver.findElement(By.xpath("Xpath of frame"));
driver.switchTo().frame(iframe);
//Perform your Task.
driver.switchTo().defaultContent();// Iframe is Switched to Main Again
Check this links for frame Switch:-
Click here
Hi Ketan.
The problem with your code might be wait issue. Once you click on continue button in the pop-up window, it requires some time interact with the next element. So for those you need to declare some with in your code.
Check this link for waits
Here is the working code. I tried it. please check this, it will resolve your problem.
import java.util.concurrent.TimeUnit;
import org.openqa.selenium.By;
import org.openqa.selenium.WebDriver;
import org.openqa.selenium.WebElement;
import org.openqa.selenium.firefox.FirefoxDriver;
import org.openqa.selenium.support.ui.Select;
public class userId {
public static void main(String[] args) throws InterruptedException {
WebDriver driver = new FirefoxDriver();
driver.manage().timeouts().implicitlyWait(15, TimeUnit.SECONDS);
driver.manage().window().maximize();
driver.get("https://qlb21.resources.hewitt.com/cl77ybr5qc/ybr5cl772b/CsLogn010InptOpen.do?fTkn=539f4eddc99aef9eb1c8da11d13a3654&fWdw=intro&eWlmYBR5ClntId=00398&wdw=primary&fPg=%2FCsLogn005WelcOpen");
System.out.println("Entered Url");
WebElement frame=driver.findElement(By.xpath("//*[@id='lightbox_iframe_cookieBanner']"));
driver.switchTo().frame(frame);
driver.findElement(By.xpath("//*[@id='lightboxarea']/div/div/a[1]")).click();
driver.switchTo().defaultContent();
driver.findElement(By.xpath("//*[@id='usrId']")).sendKeys("hari");
System.out.println("Entered the userid");
driver.findElement(By.xpath("//*[@id='pswd']")).sendKeys("Password");
System.out.println("Entered the Password");
}
}