SeleniumHQ / selenium

A browser automation framework and ecosystem.
https://selenium.dev
Apache License 2.0
30.53k stars 8.16k forks source link

Selenium(JAVA) - Handling notifications in mozilla firefox #6135

Closed SudeeptMohan closed 5 years ago

SudeeptMohan commented 6 years ago

Browser - Mozilla Firefox Selenium Version - 3.12 Test NG - version 6.14.2 OS - Windows 10 Browser - Mozilla Firefox (59.02)

Problem - The website throws notification and navigation is blocked without user action.We want selenium to take the action when notification box opens up. In the following code the method - openProfilePage() fails to execute because of selenium not taking action for the notification.

Code - package testngDemo;

import org.testng.annotations.Test; import org.testng.annotations.BeforeMethod; import java.util.concurrent.TimeUnit; import org.openqa.selenium.By; import org.openqa.selenium.Capabilities; import org.openqa.selenium.WebDriver; import org.openqa.selenium.WebElement; import org.openqa.selenium.firefox.FirefoxDriver; import org.openqa.selenium.firefox.FirefoxProfile; import org.openqa.selenium.firefox.internal.ProfilesIni; import org.testng.annotations.AfterMethod; import org.testng.annotations.DataProvider;

public class TestNgDemo {

WebDriver driver;

@Test(dataProvider = "dp",priority=1)

public void login(String username, String password) {

WebElement u_name = driver.findElement(By.id("email"));
u_name.sendKeys(username);

WebElement p_word = driver.findElement(By.id("pass"));
p_word.sendKeys(password);

driver.findElement(By.id("u_0_2")).click();

}

@test (priority = 0) public void openWebsite() { System.setProperty("webdriver.gecko.driver","C:\Marionette\geckodriver.exe"); driver = new FirefoxDriver(); driver.manage().timeouts().implicitlyWait(10, TimeUnit.SECONDS); driver.get("https://www.facebook.com");

}

@test(priority=2,dependsOnMethods="login") public void openProfilePage() { driver.findElement(By.className("_1vp5")).click(); }

@AfterMethod public void afterMethod() {

}

@dataProvider public Object[][] dp() { Object[][] data = new Object[1][2]; data[0][0]="your_fb_username"; data[0][1]="your_fb_password"; return data; } }

barancev commented 5 years ago

Triaging old issues whille preparing to 4.0 release.

What kind of notifications is this issue about? I can't reproduce the issue with the current Facebook layout.

diemol commented 5 years ago

Closing as we didn't get any more replies from the OP.