gpt4 book ai didi

java - 在没有 http 或 https 的情况下在 selenium 中传递 URL

转载 作者:塔克拉玛干 更新时间:2023-11-02 19:16:13 25 4
gpt4 key购买 nike

我想检查 URL 是否为 https?

为此:
我需要传递没有 http/https 的 URL。
例如:driver.get("google.com");driver.get("http://google.com");

谁能帮帮我。是否可以自动执行此类场景?

提前致谢。

最佳答案

driver.get() 需要以“http”/“https”开头的有效 URL。但是,driver.get("http://www.google.com") 将导航到“https://www.google.com

对于解析你可以使用startsWith方法

String url = driver.getCurrentUrl();
if (url.startsWith("https")) {
// url is https
}
else {
// url is http
}

关于java - 在没有 http 或 https 的情况下在 selenium 中传递 URL,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/34986816/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com