简体   繁体   English

如果页面未完全加载并且我的网络驱动程序所需的等待时间已经结束,如何获取URL?

[英]How do I get URL if page isn't completely loaded and my webdriver desired waiting time is already over?

I've been trying to extract the URL if the page hasn't finished loading but I want the URL if driver wait time(10 sec) is over and moves to throw a custom exception. 如果页面尚未完成加载,我一直在尝试提取URL,但是如果驱动程序等待时间(10秒)结束并且要抛出自定义异常,我希望获得URL。 I've tried window.location.href , window.location.pathname , etc but they returns null. 我试过window.location.hrefwindow.location.pathname等,但是它们返回null。

Window Location 窗口位置

The JavaScript window.location object can be used to get the current page address (URL) and to redirect the browser to a new page. JavaScript window.location对象可用于获取当前页面地址(URL)并将浏览器重定向到新页面。 The window.location object can be written without the window prefix. 可以编写不带窗口前缀的window.location对象。 Some examples: 一些例子:

  • window.location.href : returns the href (URL) of the current page window.location.href :返回当前页面的href(URL)
  • window.location.hostname : returns the domain name of the web host window.location.hostname :返回虚拟主机的域名
  • window.location.pathname : returns the path and filename of the current page window.location.pathname :返回当前页面的路径和文件名
  • window.location.protocol : returns the web protocol used (http: or https:) window.location.protocol :返回使用的Web协议(http:或https :)
  • window.location.assign : loads a new document window.location.assign :加载新文档

Page completely not loaded 页面完全未加载

Unfortunately, there is no generic step to check if page has completely loaded through Selenium. 不幸的是, 没有通用步骤可以检查页面是否已通过Selenium完全加载。 However there are certain approaches to ensure that the page is completely loaded using the following strategies: 但是,有一些方法可以确保使用以下策略完全加载页面:

Note : You can find a detailed discussion in Do we have any generic funtion to check if page has completely loaded in Selenium 注意 :您可以在“我们是否有任何通用功能检查页面是否已完全装入Selenium中”中找到详细讨论。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM