我可以如何处理相机,通知和位置警报(基于网络)在 selenium 与java?

ykejflvf  于 2023-01-19  发布在  Java
关注(0)|答案(1)|浏览(84)

它不工作与开关和sikuli

driver.switchTo().alert().accept();
String photopath= "C:\\Users\\Pictures\\";
        Screen s= new Screen();
        Pattern np = new Pattern("picture\\abc.png");
        try {
            s.click(np);
        } catch (FindFailed e) {
            e.printStackTrace();
                }

[一个月一次](一个月一次)

Is there any alternative of sikuli or how can it accept normally.[](https://i.stack.imgur.com/CTwov.png)
h9vpoimq

h9vpoimq1#

使用这个基于Web的警报,它真的工作:Otherwise, default allow camera from the site setting.

public static void main(String[] args) {
    ChromeOptions options = new ChromeOptions();
    HashMap<String, Integer> contentsettings = new HashMap<String, Integer>();
    HashMap<String, Object> profile = new HashMap<String, Object>();
    HashMap<String, Object> prefs = new HashMap<String, Object>();
    contentsettings.put("media_stream", 1);
    /*
     * for location : "geolocation" 
     * For camera and microphone : "media_stream" 
     * For notification: "notifications"
     */
    profile.put("managed_default_content_settings", contentsettings);
    prefs.put("profile", profile);
    options.setExperimentalOption("prefs", prefs);
    driver = new ChromeDriver(options);

相关问题