【问题标题】:How to send text to username and password fields within Basic Authentication? [duplicate]如何将文本发送到基本身份验证中的用户名和密码字段? [复制]
【发布时间】:2019-03-29 20:14:13
【问题描述】:

请帮帮我!我尝试进入我的应用程序 (https://testing.shipnext.com/),但模式窗口不允许我。我必须输入登录名/密码,但我做不到。我尝试使用此代码:

警报警报;

@BeforeClass
public static void setup(){
    System.setProperty("webdriver.chrome.driver", "/home/qa-1/IdeaProjects/chromedriver");
    driver = new ChromeDriver();
    loginPage = new LoginPage(driver);
    driver.manage().window().maximize();
    driver.manage().timeouts().implicitlyWait(10, TimeUnit.SECONDS);
    driver.get("https://testing.shipnext.com/");
}

@Test
public void alertText(){
    alert = driver.switchTo().alert();
    alert.sendKeys("myLogin");

【问题讨论】:

    标签: java selenium selenium-webdriver basic-authentication


    【解决方案1】:

    请使用下面的声明和凭据(有效的用户名和密码)来启动 URL。

    driver.get("https://**username**:**password**@testing.shipnext.com/");
    

    【讨论】:

    • 我可以进入网站,但是当我尝试使用我的登录名/psw 登录时出现错误:
    • promiseMiddleware.js:59 类型错误:无法在“窗口”上执行“获取”:无法从包含凭据的 URL 构造请求:/api/v1/auth/sign_in at api.js: 103 at tryCatch (runtime.js?1791:63) at Generator._invoke (runtime.js?1791:337) at Generator.prototype.(/anonymous function) [as next] (shipnext:atdnsshinc@testing.shipnext.com/assets/…) at step (asyncToGenerator.js :17) at asyncToGenerator.js:35 at new Promise () at new F (_export.js:35) at a
    猜你喜欢
    • 2014-05-10
    • 2016-09-14
    • 1970-01-01
    • 2016-04-19
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2018-09-19
    相关资源
    最近更新 更多