1

在过去的 10 年里,我一直在进行产品开发和测试,并在几年前接手了我们公司的一种产品的研发硒测试。我正在更新我们的 C# 测试框架,该框架在一系列浏览器中测试我们产品的网络服务器功能。PM 最近添加的浏览器之一是 Opera。目前,我们在我们的框架中使用以下版本控制:

Selenium WebDriver:V3.141.0.0 Selenium WebDriver.Support:V3.141.0.0 Operadriver_win64 V2.42 Opera 浏览器:58.0.3135.127

PM 指定我们必须确保为我们的客户支持 Opera 58.x,因为这将在我们的下一个产品版本中记录给客户,所以不幸的是,我必须针对这个特定版本进行测试。

我在网上做了一些关于自动化 Opera 的广泛阅读。我从 GitHub 确定我需要 Operachromiumdriver v2.42 用于我的特定 58.x 版本的 Opera。

string localappdata = Environment.GetEnvironmentVariable("LocalAppData");
operadriverDir = Directory.GetCurrentDirectory();
operadriverExe = @"operadriver.exe";

OperaOptions operaOptions = new OperaOptions
{
     LeaveBrowserRunning = false,
     BinaryLocation = localappdata + @"\Programs\Opera\58.0.3135.127\opera.exe"
};
operaOptions.AddArgument("--user-data-dir=" + localappdata + @"\Google\Chrome\Opera\User Data");

var service_opera = OperaDriverService.CreateDefaultService(operadriverDir, operadriverExe);
service_opera.EnableVerboseLogging = true;
service_opera.Start();
int port = service_opera.Port;

operaOptions.AddArgument("--remote-debugging-port=" + port.ToString());
driver = new OperaDriver(service_opera, operaOptions);

当我以管理员身份使用 nunit 运行上述代码时,依次发生以下 3 件事:

  1. Operadriver.exe 控制台窗口启动
  2. OperaSoftware.OperaWebBrowser.1610649940 控制台窗口启动
  3. Opera.exe 实例启动

此时,nunit 指示此测试出现以下错误: SystemTest_S7_1200.Communications._45WebServer._456_WebServer_Opera._45001_BasicFunctionality: SetUp : OpenQA.Selenium.WebDriverException : unknown error: Opera failed to start: crashed (Opera not reachable) (进程从chrome 位置 C:\Users\System Test\AppData\Local\Programs\Opera\58.0.3135.127\opera.exe 不再运行,因此 OperaDriver 假设 Opera 已崩溃。)(驱动程序信息:OperaDriver=2.42.3135( O58),平台=Windows NT 10.0.17763 x86_64)

I was a bit confused by this error because I can clearly see Opera started. So, I got looking at the logging for operadriver.exe:

Starting OperaDriver 2.42.3135 (O58) on port 37604
Only local connections are allowed.
[1612215723.848][INFO]: [0d995150afccdcc03195334ce4f36367] COMMAND InitSession {
   "capabilities": {
      "firstMatch": [ {
         "acceptInsecureCerts": true,
         "browserName": "opera"
      } ]
   },
   "desiredCapabilities": {
      "acceptInsecureCerts": true,
      "browserName": "opera",
      "operaOptions": {
         "args": [ "--user-data-dir=C:\\Users\\System Test\\AppData\\Local\\Google\\Chrome\\Opera\\BlankUserData", "--disable-extensions", "--remote-debugging-port=37604" ],
         "binary": "C:\\Users\\System Test\\AppData\\Local\\Programs\\Opera\\58.0.3135.127\\opera.exe"
      }
   }
}
[1612215723.850][INFO]: Populating Preferences file: {
   "alternate_error_pages": {
      "enabled": false
   },
   "autofill": {
      "enabled": false
   },
   "browser": {
      "check_default_browser": false
   },
   "distribution": {
      "import_bookmarks": false,
      "import_history": false,
      "import_search_engine": false,
      "make_chrome_default_for_user": false,
      "skip_first_run_ui": true
   },
   "dns_prefetching": {
      "enabled": false
   },
   "profile": {
      "content_settings": {
         "pattern_pairs": {
            "https://*,*": {
               "media-stream": {
                  "audio": "Default",
                  "video": "Default"
               }
            }
         }
      },
      "default_content_setting_values": {
         "geolocation": 1
      },
      "default_content_settings": {
         "geolocation": 1,
         "mouselock": 1,
         "notifications": 1,
         "popups": 1,
         "ppapi-broker": 1
      },
      "password_manager_enabled": false
   },
   "safebrowsing": {
      "enabled": false
   },
   "search": {
      "suggest_enabled": false
   },
   "translate": {
      "enabled": false
   }
}
[1612215723.854][INFO]: Populating Local State file: {
   "ab_testing": {
      "uid": "MjRlNmUzZmEtNDJmNS00YTI3LWI4YTQtMTk1MTY2YmEwMTU3"
   },
   "background_mode": {
      "enabled": false
   },
   "browserjs": {
      "version": "1540378800"
   },
   "component_updater": {
      "widevine": {
         "up_to_date": false
      }
   },
   "hardware_acceleration_mode_previous": true,
   "location": {
      "country": "us",
      "country_from_server": "unknown"
   },
   "partner_content": {
      "version": {
         "default": 61
      }
   },
   "password_manager": {
      "os_password_blank": false,
      "os_password_last_changed": "13255103709737702"
   },
   "shutdown": {
      "num_processes": 2,
      "num_processes_slow": 1,
      "performed": true,
      "type": 2
   },
   "ssl": {
      "rev_checking": {
         "enabled": false
      }
   },
   "startup_metric": {
      "last_startup_timestamp": "13256688446647647",
      "last_startup_version": "71.0.3578.98",
      "same_version_startup_count": 19
   },
   "subresource_filter": {
      "ruleset_version": {
         "checksum": 1918231743,
         "content": "9.18.0",
         "format": 23
      }
   },
   "update": {
      "last_verify_time": "13256674004800030"
   },
   "updateclientdata": {
      "apps": {
         "aemomkdncapdnfajjbbcbdebjljbpmpj": {
            "cohort": "",
            "cohortname": "",
            "dlrc": 5145,
            "pf": "cc1d9041-3721-4533-b352-426560ac1a21"
         },
         "gcmjkmgdlgnkkcocmoeiminaijmmjnii": {
            "cohort": "1:bm1:xa9@0.01",
            "cohortname": "M54ToM99",
            "dlrc": 5145,
            "pf": "6fd7e0e8-4cbf-4fa5-9f1e-8f3d1990b5b7"
         },
        "hfnkpimlhhgieaddgfemjhofmfblmnib": {
            "cohort": "1:jcl:",
            "cohortname": "Auto",
            "dlrc": 5145,
            "pf": "e3b2fb1e-0ebb-45a6-a5e9-6a77ef613f0e"
         },
         "oimompecagnajdejgnnjijobebaeigek": {
            "cohort": "",
            "cohortname": "",
            "dlrc": 5145,
            "pf": "2b5860db-7759-4ddf-b9ad-3ecceb3ec7c8"
         }
      }
   }
}
[1612215723.864][INFO]: Launching Opera: "C:\Users\System Test\AppData\Local\Programs\Opera\58.0.3135.127\opera.exe" --disable-background-networking --disable-client-side-phishing-detection --disable-default-apps --disable-extensions --disable-extensions-except="C:\Users\SYSTEM~1\AppData\Local\Temp\scoped_dir912_5937\internal" --disable-hang-monitor --disable-popup-blocking --disable-presto-profile-migration --disable-prompt-on-repost --disable-sync --disable-update --disable-usage-statistics-question --disable-web-resources --enable-automation --enable-logging --force-fieldtrials=SiteIsolationExtensions/Control --ignore-certificate-errors --log-level=0 --metrics-recording-only --no-default-browser-check --no-first-run --password-store=basic --ran-launcher --remote-debugging-port=37604 --test-type=webdriver --use-mock-keychain --user-data-dir="C:\Users\System Test\AppData\Local\Google\Chrome\Opera\BlankUserData"
[1612215723.870][DEBUG]: DevTools HTTP Request: http://localhost:37604/json/version
[1612215723.874][DEBUG]: DevTools HTTP Request failed
[1612215723.953][DEBUG]: DevTools HTTP Request: http://localhost:37604/json/version
[1612215723.954][DEBUG]: DevTools HTTP Request failed
[1612215724.014][DEBUG]: DevTools HTTP Request: http://localhost:37604/json/version
[1612215724.016][DEBUG]: DevTools HTTP Request failed
[1612215724.076][DEBUG]: DevTools HTTP Request: http://localhost:37604/json/version
[1612215724.079][DEBUG]: DevTools HTTP Request failed
[1612215724.140][DEBUG]: DevTools HTTP Request: http://localhost:37604/json/version
[1612215724.141][DEBUG]: DevTools HTTP Request failed
[1612215724.217][DEBUG]: DevTools HTTP Request: http://localhost:37604/json/version
[1612215724.220][DEBUG]: DevTools HTTP Request failed
[1612215724.283][DEBUG]: DevTools HTTP Request: http://localhost:37604/json/version
[1612215724.285][DEBUG]: DevTools HTTP Request failed
[1612215724.360][DEBUG]: DevTools HTTP Request: http://localhost:37604/json/version
[1612215724.364][DEBUG]: DevTools HTTP Request failed
[1612215724.425][DEBUG]: DevTools HTTP Request: http://localhost:37604/json/version
[1612215724.448][DEBUG]: DevTools HTTP Request failed
[1612215724.518][DEBUG]: DevTools HTTP Request: http://localhost:37604/json/version
[1612215724.854][DEBUG]: DevTools HTTP Request failed
[1612215724.946][INFO]: [0d995150afccdcc03195334ce4f36367] RESPONSE InitSession ERROR unknown error: Opera failed to start: crashed
  (Opera not reachable)
  (The process started from chrome location C:\Users\System Test\AppData\Local\Programs\Opera\58.0.3135.127\opera.exe is no longer running, so OperaDriver is assuming that Opera has crashed.)
[1612215724.983][DEBUG]: Log type 'driver' lost 0 entries on destruction
[1612215724.997][DEBUG]: Log type 'browser' lost 0 entries on destruction

在 OperaSoftware.OperaWebBrowser 控制台中,记录了以下内容:

[8116:8468:0201/164204.426:ERROR:tcp_socket_win.cc(355)] bind() returned an error: Only one usage of each socket address (protocol/network address/port) is normally permitted. (0x2740)
[8116:8468:0201/164204.442:ERROR:tcp_socket_win.cc(355)] bind() returned an error: Only one usage of each socket address (protocol/network address/port) is normally permitted. (0x2740)
[8116:8468:0201/164204.473:ERROR:devtools_http_handler.cc(295)] Cannot start http server for devtools.
[8116:3184:0201/164205.297:ERROR:gpu_process_transport_factory.cc(967)] Lost UI shared context.

我知道我真的很接近让它工作......我认为我的障碍是 DevTools HTTP 请求在多次尝试时失败,最终导致 InitSession 失败,因为它无法到达/附加到 Opera。

我的问题......我在这里错过了什么?对于我们测试的其他浏览器,如 Chrome、IE11、FF 等,启动 webdriver 并附加到浏览器实例一点也不难。恐怕我所缺少的一切都是显而易见的,而我只是没有看到。当然,根据我在网上的研究,在使用 Opera 进行测试时,我没有看到任何明确和明确的信息。绑定到特定版本使这个问题成为一个障碍。非常感谢任何输入。

4

0 回答 0