如果任何人使用chrome浏览器登录任何应用程序,则会出现通知弹出窗口,以保存密码/允许通知。如何通过selenium web-driver处理此通知弹出窗口?有时会出现两个弹出窗口(一个是保存密码,另一个是允许通知),.I已经尝试使用警报类处理,但无法在这方面succeeded.kindly帮助我。
发布于 2017-05-26 03:33:29
您可以打开使用ChromeOptions类。以下是示例代码。
ChromeOptions chrome_Profile = new ChromeOptions();
chrome_Profile.addArguments("chrome.switches","--disable-extensions");
chrome_Profile.addArguments("--disable-save-password");
chrome_Profile.addArguments("disable-infobars");
System.setProperty("webdriver.chrome.driver","c/chromedriver.exe");
//Passing chrome_Profile while initializing the ChromeDriver
WebDriver driver = new ChromeDriver(chrome_Profile);如果这有帮助,请告诉我。
发布于 2018-01-22 17:47:07
你可以使用下面的代码来允许chrome发送通知:
ChromeOptions options=new ChromeOptions();
Map<String, Object> prefs=new HashMap<String,Object>();
prefs.put("profile.default_content_setting_values.notifications", 1);
//1-Allow, 2-Block, 0-default
options.setExperimentalOption("prefs",prefs);
ChromeDriver driver=new ChromeDriver(options);发布于 2018-05-30 20:08:48
@Pritesh patel
it didnt work for me.. I want to allow the flash to run
package com.selenium.Basics;
import java.util.HashMap;
import java.util.Iterator;
import java.util.List;
import java.util.Map;
import java.util.Set;
import java.util.concurrent.TimeUnit;
import org.openqa.selenium.Alert;
import org.openqa.selenium.By;
import org.openqa.selenium.WebDriver;
import org.openqa.selenium.WebElement;
import org.openqa.selenium.chrome.ChromeDriver;
import org.openqa.selenium.chrome.ChromeOptions;
import org.openqa.selenium.remote.CapabilityType;
import org.openqa.selenium.remote.DesiredCapabilities;
import org.openqa.selenium.support.ui.ExpectedConditions;
import org.openqa.selenium.support.ui.WebDriverWait;
import Flash.FlashObjectWebDriver;
public class GuruPgm14FlashTesting {
public static void main(String[] args) throws Exception {
// TODO Auto-generated method stub
String driverPath="C:\\selenium\\chromedriver.exe";
System.setProperty("webdriver.chrome.driver", driverPath);
ChromeOptions options=new ChromeOptions();
Map<String, Object> prefs=new HashMap<String,Object>();
prefs.put("profile.default_content_setting_values.notifications", 1);
//1-Allow, 2-Block, 0-default
options.setExperimentalOption("prefs",prefs);
WebDriver driver=new ChromeDriver(options);
driver.get("http://demo.guru99.com/test/flash-testing.html");
Thread.sleep(5000);
driver.findElement(By.xpath("//embed[@play='false']")).click();
System.out.println("Clicked to allow the addon");
Thread.sleep(5000);
FlashObjectWebDriver fdriver= new FlashObjectWebDriver(driver, "myFlashVideo");
fdriver.callFlashObject("Play");
Thread.sleep(5000);
fdriver.callFlashObject("StopPlay");
Thread.sleep(5000);
fdriver.callFlashObject("SetVariable","/:message","Flash testing using selenium Webdriver");
System.out.println(fdriver.callFlashObject("GetVariable","/:message"));
}
}https://stackoverflow.com/questions/44184668
复制相似问题