Reputation: 296
There is a scenario where I get the modal dialog box when I tried to login.
I am not able to handle login scenario because webdriver is not getting access to the modal dialog box. Is there any way to handle this?
See the details in below image:
public class TwitterLogin
{
static WebDriver driver;
static String baseUrl="myURL";
public static void main(String[] args)
{
driver= new FirefoxDriver();
driver.get(baseUrl);
driver.manage().window().maximize();
//******Click on Login Link**********//
WebElement LoginButton= driver.findElement(By.xpath("//button[@class='Button StreamsLogin js-login']"));
LoginButton.click();
WebElement UsernameTextbox= driver.findElement(By.xpath("//input[contains(@name,'email]')]"));
UsernameTextbox.clear();
UsernameTextbox.sendKeys("uName");
WebElement PasswdTextbox=driver.findElement(By.xpath("//input[contains(@type,'password')]"));
PasswdTextbox.clear();
PasswdTextbox.sendKeys("1234");
}
}
After clicking on Login button, I'm not able to enter username & password.
Upvotes: 3
Views: 15804
Reputation: 4671
In Python , work with Selenium 4 and later versions:
copy selector path
wait to open new dialog
time.sleep(5)
phone_path='div:nth-child(4) > span > div:nth-child(3) > button'
log_in_phone = driver.find_element(By.CSS_SELECTOR, phone_path)
log_in_phone.click()
Upvotes: 0
Reputation: 3004
just write the following code after click on login button:
Thread.sleep(3000); //i use here wait implicit wait. Try to use explicit wait here.
driver.findElement(By.cssSelector("a.Icon.Icon--close.Icon--medium.dismiss")).click();
Upvotes: 3