【问题标题】:Selenium How to sendKeys on "could not found find on the page"Selenium 如何在“无法在页面上找到”上发送密钥
【发布时间】:2018-05-22 01:50:24
【问题描述】:

我正在编写一个具有自动登录功能的 selenium 驱动程序,但我在登录表单上找不到任何内容。

如何在此表单中输入密码和帐户文本?

Blank form need to input text

【问题讨论】:

    标签: java selenium selenium-webdriver selenium-chromedriver selenium-ide


    【解决方案1】:

    这不是 HTML 表单。这是操作系统提供的对话框,而不是浏览器。所以你不能使用 selenium 来自动化它。

    您可以使用Java Class Robot 来操作它,但Robot 类只能在您的脚本所在的本地操作对话框。如果您使用 RemoteWebDriver 并在远程机器上打开浏览器,Robot 类将无法工作。

    据我所知,没有好的解决方案可以同时支持本地和远程案例。

    【讨论】:

    • 我将尝试查看机器人包。您是否给我任何可以自动登录此表单的技术或库甚至任何语言?
    • 希望这篇文章能对你有所帮助:guru99.com/using-robot-api-selenium.html
    • 我尝试使用机器人,但它不起作用。 Selenium 等待无限加载页面,因此它无法运行下一个代码。我尝试为输入机器人创建新线程,自动按下功能运行但表单上没有任何输入
    【解决方案2】:

    您在谈论基本身份验证,并且有一些解决方案。

    Selenium - Basic Authentication via url

    通过 url 中的凭据(不再适用于 chrome)或 chrome 中的远程调试。

    Chrome remote debugging in a seleniumgrid

    【讨论】:

    • 你能帮我先在localhost(单机)上运行自动程序吗?
    • 您可以做的最简单的事情是使用 chrome 版本 user:pass@url”。如果不是,您需要通过 web 服务连接到 chrome 调试器:medium.com/@sahajamit/…
    【解决方案3】:

    试试这个

    import org.openqa.selenium.NoAlertPresentException;	
    import org.openqa.selenium.Alert;
    driver.switchTo().alert().sendKeys("username" + Keys.TAB + "password"); 
    driver.switchTo().alert().accept();

    如果你在 java 中使用 selenium 试试这个

    import org.openqa.selenium.NoAlertPresentException;	
    import org.openqa.selenium.Alert;
    driver.switchTo().alert().sendKeys("username" + Keys.TAB + "password"); 
    driver.switchTo().alert().accept();

    【讨论】:

    • 请给我那里的功能包库
    • 我在 Selenium for Java 上找不到 SetAuthenticationCredentials() 函数
    猜你喜欢
    • 1970-01-01
    • 2017-05-24
    • 1970-01-01
    • 2016-03-19
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2021-01-01
    • 1970-01-01
    相关资源
    最近更新 更多