automation - 使用 WireMock 模拟 Appium 的行为时无法创建会话
问题描述
我正在尝试使用 WireMock 来模拟 Appium 的行为。
我面临的问题是:我的 POST 存根能够使用我设置的响应代码(我使用 Wireshark 进行监控)来响应我,但它会引发与会话创建相关的异常。
我尝试创建会话以供参考的 POST 存根:
- 试验 1:
wireMockRule.stubFor(post(urlEqualTo("/wd/hub/session”)).
withRequestBody(matching(“JSON representation of set of desired capabilities specific to application"))
.willReturn(aResponse().
withStatus(200).
withHeader("Content-Type", "application/json”).
withBody("{\"sessionId\":\"e523dc70-c068-46e7-b966-8462401119b4\",\"status\":0,\"value\":\"Created Session\"}")));
结果:“无法创建新会话,因为未找到需要 HttpClient、InputStream 和 long 的 'createSession' 或无法访问”异常。
试验 2:刚刚从上面的存根中删除了请求正文
wireMockRule.stubFor(post(urlEqualTo("/wd/hub/session”))
.willReturn(aResponse().
withStatus(200).
withHeader("Content-Type", "application/json”).
withBody("{\"sessionId\":\"e523dc70-c068-46e7-b966-8462401119b4\",\"status\":0,\"value\":\"Created Session\"}")));
结果:
org.openqa.selenium.SessionNotCreatedException:无法创建新的远程会话”异常。
环境参考:
Appium 的 Java 客户端:6.0.0
Selenium 独立服务器:3.12.0
Java 的 Selenium 客户端:3.12.0
请帮忙。
解决方案
This does not really seem to related to WireMock?
Maybe you can switch to the .NET version from WireMock to simulate your calls?
推荐阅读
- java - Spring Data REST - collectionResourceRel 与路径
- javascript - 范围输入偏移量计算不匹配
- powerbi - Power BI“应用查询更改”运行时间不可行
- visual-studio - T4 迭代解决方案文件夹中的项目
- python - 如何创建非阻塞线程?
- visual-studio-code - 集成终端中缺少 nvm、节点等路径
- php - 使用 Facebook 登录时从 chrome 扩展程序访问网站
- jsf - JSF 错误:找不到基本名称 xxxx、语言环境 xxxx 的捆绑包
- r - 如何解决 predict.rpart(fitTree, data = hypo_mode, type = "class") 中的错误:“rpart”对象的预测无效?
- sql - 从同一个表中获取不同ID的一列的值