Warning: file_get_contents(/data/phpspider/zhask/data//catemap/9/java/329.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Java 浏览器登录到页面,使用Selenium进行处理_Java_Selenium_Authentication_Selenium Webdriver - Fatal编程技术网

Java 浏览器登录到页面,使用Selenium进行处理

Java 浏览器登录到页面,使用Selenium进行处理,java,selenium,authentication,selenium-webdriver,Java,Selenium,Authentication,Selenium Webdriver,我是selenium的新手,我正在尝试自动登录到一个页面。 但在实际登录之前,我会得到额外凭证的弹出窗口。 步骤: 在新打开的浏览器(Firefox/Chrome)中粘贴页面地址。 单击enter, 弹出窗口出现,询问登录名和密码以加载页面。 我手动填充它们,我得到了我想要测试的页面 我无法检查此弹出元素以获取XPath或CSS选择器,如果没有它们,我的selenium脚本将失败 当我试图使用https://user:password@pageaddress.com我得到了一个页面,但没有任何

我是selenium的新手,我正在尝试自动登录到一个页面。 但在实际登录之前,我会得到额外凭证的弹出窗口。 步骤: 在新打开的浏览器(Firefox/Chrome)中粘贴页面地址。 单击enter, 弹出窗口出现,询问登录名和密码以加载页面。 我手动填充它们,我得到了我想要测试的页面

我无法检查此弹出元素以获取XPath或CSS选择器,如果没有它们,我的selenium脚本将失败

当我试图使用
https://user:password@pageaddress.com
我得到了一个页面,但没有任何效果。 我正在点击“唱歌”,但页面是静态的

你能提出建议吗

致以最良好的祝愿, Piotr测试,链接“基本身份验证测试”

package selenium;

import java.util.List;

import org.openqa.selenium.By;
import org.openqa.selenium.WebDriver;
import org.openqa.selenium.WebElement;

public class BasicAuhenticationTest extends WebDriverBase {

    public static void main(String[] args) {
        WebDriver driver = startChromeDriver();
        String protocol = "https://";
        String username = "guest";
        String password = "guest";
        String url = "jigsaw.w3.org/HTTP/Basic/";
        String urlFull = protocol + username + ":" + password + "@" + url;
        driver.get(urlFull);
        List<WebElement> paragraphs = driver.findElements(By.tagName("p"));
        for (WebElement paragraph: paragraphs) {
            System.out.println(paragraph.getText());
        }
        driver.quit();
    }
    
}
谢谢,

我找到了答案。
我无法用Firefox解决这个问题,但Chrome开始工作。

好的,我知道这是我想测试的页面的基本身份验证,但如何处理?使用JavascriptExecutor也不起作用。你用的是什么语言?Java,我从不同的角度尝试过。我之所以关注firefox,是因为Chrome不在默认的预期位置。对于chrome,我得到的错误是找不到chrome.exe的二进制文件。设置选项。二进制\u位置。。。不适用于我。如果您想通过selenium登录,您需要打开登录页面。您需要获取WebElement,然后发送密钥。我想这一页对你有帮助
Starting ChromeDriver 90.0.4430.24 (4c6d850f087da467d926e8eddb76550aed655991-refs/branch-heads/4430@{#429}) on port 29989
Only local connections are allowed.
Please see https://chromedriver.chromium.org/security-considerations for suggestions on keeping ChromeDriver safe.
ChromeDriver was started successfully.
Kvě 28, 2021 3:02:37 ODP. org.openqa.selenium.remote.ProtocolHandshake createSession
INFO: Detected dialect: W3C


Your browser made it!