美文网首页
Selenium webdriver 体系结构摘要

Selenium webdriver 体系结构摘要

作者: limus | 来源:发表于2020-09-15 11:37 被阅读0次

Selenium - Webdriver 关系图

image.png

Selenium1.0 javascript库 结构

image.png

FireFox

image.png
FirefoxDriver.prototype.getElementAttribute =函数(响应,参数){
  var element = Utils.getElementAt(parameters.id,
                                  response.session.getDocument());
  var attributeName = parameters.name;

  response.value = webdriver.element.getAttribute(element,attributeName);
  response.send();
};

IE 驱动程序

image.png

Selenium Core

image.png

chromedriver

Chromedriver 最后调用的是chrome的api,下面是一段 等待页面加载完成的代码

Status ChromeDesktopImpl::WaitForPageToLoad(
    const std::string& url,
    const base::TimeDelta& timeout_raw,
    std::unique_ptr<WebView>* web_view,
    bool w3c_compliant) {
  Timeout timeout(timeout_raw);
  std::string id;
  WebViewInfo::Type type = WebViewInfo::Type::kPage;
  while (timeout.GetRemainingTime() > base::TimeDelta()) {
    WebViewsInfo views_info;
    Status status = devtools_http_client_->GetWebViewsInfo(&views_info);   // 开发者工具
    if (status.IsError())
      return status;

    for (size_t i = 0; i < views_info.GetSize(); ++i) {
      const WebViewInfo& view_info = views_info.Get(i);
      if (base::StartsWith(view_info.url, url, base::CompareCase::SENSITIVE)) {
        id = view_info.id;
        type = view_info.type;
        break;
      }
    }
    if (!id.empty())
      break;
    base::PlatformThread::Sleep(base::TimeDelta::FromMilliseconds(100));
  }
  if (id.empty())
    return Status(kUnknownError, "page could not be found: " + url);

  const DeviceMetrics* device_metrics = devtools_http_client_->device_metrics();
  if (type == WebViewInfo::Type::kApp ||
      type == WebViewInfo::Type::kBackgroundPage) {
    // Apps and extensions don't work on Android, so it doesn't make sense to
    // provide override device metrics in mobile emulation mode, and can also
    // potentially crash the renderer, for more details see:
    // https://code.google.com/p/chromedriver/issues/detail?id=1205
    device_metrics = nullptr;
  }

相关文章

网友评论

      本文标题:Selenium webdriver 体系结构摘要

      本文链接:https://www.haomeiwen.com/subject/aloxyktx.html