java 无法访问镶边设置

6yt4nkrj  于 2022-12-02  发布在  Java
关注(0)|答案(1)|浏览(118)

我正在制作一个需要自动登录的应用程序。为此,我使用selenium打开一个新的选项卡,并通过Web剪贴获取用户和密码,但我得到了一个java.net。未知协议:chrome当tryng得到源代码。我怎么能解决这个问题?thxx

System.setProperty("webdriver.gecko.driver", ".\\driver/chromedriver.exe");

        WebDriver driver = new ChromeDriver();

        driver.manage().window().maximize();

        driver.get("chrome://settings/passwords?search=contra");

        try {
            URL dirURL = new URL("chrome://settings/passwords?search=contra");
            InputStream entry = dirURL.openStream();
            BufferedReader reader = new BufferedReader(new InputStreamReader(entry));

            String line = "";
            String sourceCode = "";
            do {
                sourceCode += line + "\n";
                line = reader.readLine();
            } while (line != null);
            
            System.out.println(sourceCode);
            
            
        } catch (MalformedURLException e) {
            // TODO Auto-generated catch block
            e.printStackTrace();
        } catch (IOException e) {
            // TODO Auto-generated catch block
            e.printStackTrace();
        }
bmp9r5qi

bmp9r5qi1#

使用时:

WebDriver driver = new ChromeDriver();

所以在开头就改为:

webdriver.gecko.driver

您需要提供:

webdriver.chrome.driver

相关问题