当前位置: 首页 > 面试题库 >

Appium-创建会话-错误:应提供JSONWP或W3C功能

陶锋
2023-03-14
问题内容

我无法让Appium启动Android会话,也没有找到与我在网上搜索时收到的错误消息相关的任何内容。

当我运行测试时,Appium转储此日志:

[debug] [MJSONWP] Calling AppiumDriver.createSession() with args: [null,null,[{"desiredCapabilities":{"platformVersion":"7.0","appiumVersion":"1.11.1","automationName":"UiAutomator2","platformName":"Android","deviceName":"ZX1G22GRHD","applicationName":"Absolute"}},{"requiredCapabilities":{}}]]
[debug] [BaseDriver] Event 'newSessionRequested' logged at 1552607433945 (16:50:33 GMT-0700 (Pacific Daylight Time))
[debug] [BaseDriver] Event 'newSessionStarted' logged at 1552607433945 (16:50:33 GMT-0700 (Pacific Daylight Time))
[debug] [W3C] Encountered internal error running command: Error: Either JSONWP or W3C capabilities should be provided
[debug] [W3C]     at parseCapsForInnerDriver (/Users/davethomas/.nvm/versions/node/v10.15.0/lib/node_modules/appium/lib/utils.js:58:14)
[debug] [W3C]     at AppiumDriver.createSession (/Users/davethomas/.nvm/versions/node/v10.15.0/lib/node_modules/appium/lib/appium.js:262:26)
[debug] [W3C]     at AppiumDriver.executeCommand (/Users/davethomas/.nvm/versions/node/v10.15.0/lib/node_modules/appium/node_modules/appium-base-driver/lib/basedriver/driver.js:301:19)
[debug] [W3C]     at AppiumDriver.executeCommand (/Users/davethomas/.nvm/versions/node/v10.15.0/lib/node_modules/appium/lib/appium.js:429:26)
[debug] [W3C]     at asyncHandler (/Users/davethomas/.nvm/versions/node/v10.15.0/lib/node_modules/appium/node_modules/appium-base-driver/lib/protocol/protocol.js:352:34)
[debug] [W3C]     at app.(anonymous function) (/Users/davethomas/.nvm/versions/node/v10.15.0/lib/node_modules/appium/node_modules/appium-base-driver/lib/protocol/protocol.js:489:15)
[debug] [W3C]     at Layer.handle [as handle_request] (/Users/davethomas/.nvm/versions/node/v10.15.0/lib/node_modules/appium/node_modules/express/lib/router/layer.js:95:5)
[debug] [W3C]     at next (/Users/davethomas/.nvm/versions/node/v10.15.0/lib/node_modules/appium/node_modules/express/lib/router/route.js:137:13)
[debug] [W3C]     at Route.dispatch (/Users/davethomas/.nvm/versions/node/v10.15.0/lib/node_modules/appium/node_modules/express/lib/router/route.js:112:3)
[debug] [W3C]     at Layer.handle [as handle_request] (/Users/davethomas/.nvm/versions/node/v10.15.0/lib/node_modules/appium/node_modules/express/lib/router/layer.js:95:5)
[debug] [W3C]     at /Users/davethomas/.nvm/versions/node/v10.15.0/lib/node_modules/appium/node_modules/express/lib/router/index.js:281:22
[debug] [W3C]     at Function.process_params (/Users/davethomas/.nvm/versions/node/v10.15.0/lib/node_modules/appium/node_modules/express/lib/router/index.js:335:12)
[debug] [W3C]     at next (/Users/davethomas/.nvm/versions/node/v10.15.0/lib/node_modules/appium/node_modules/express/lib/router/index.js:275:10)
[debug] [W3C]     at logger (/Users/davethomas/.nvm/versions/node/v10.15.0/lib/node_modules/appium/node_modules/morgan/index.js:144:5)
[debug] [W3C]     at Layer.handle [as handle_request] (/Users/davethomas/.nvm/versions/node/v10.15.0/lib/node_modules/appium/node_modules/express/lib/router/layer.js:95:5)
[debug] [W3C]     at trim_prefix (/Users/davethomas/.nvm/versions/node/v10.15.0/lib/node_modules/appium/node_modules/express/lib/router/index.js:317:13)
[debug] [W3C]     at /Users/davethomas/.nvm/versions/node/v10.15.0/lib/node_modules/appium/node_modules/express/lib/router/index.js:284:7
[debug] [W3C]     at Function.process_params (/Users/davethomas/.nvm/versions/node/v10.15.0/lib/node_modules/appium/node_modules/express/lib/router/index.js:335:12)
[debug] [W3C]     at next (/Users/davethomas/.nvm/versions/node/v10.15.0/lib/node_modules/appium/node_modules/express/lib/router/index.js:275:10)
[debug] [W3C]     at /Users/davethomas/.nvm/versions/node/v10.15.0/lib/node_modules/appium/node_modules/body-parser/lib/read.js:130:5
[debug] [W3C]     at invokeCallback (/Users/davethomas/.nvm/versions/node/v10.15.0/lib/node_modules/appium/node_modules/raw-body/index.js:224:16)
[debug] [W3C]     at done (/Users/davethomas/.nvm/versions/node/v10.15.0/lib/node_modules/appium/node_modules/raw-body/index.js:213:7)
[debug] [W3C]     at IncomingMessage.onEnd (/Users/davethomas/.nvm/versions/node/v10.15.0/lib/node_modules/appium/node_modules/raw-body/index.js:273:7)
[debug] [W3C]     at IncomingMessage.emit (events.js:182:13)
[debug] [W3C]     at endReadableNT (_stream_readable.js:1094:12)
[debug] [W3C]     at process._tickCallback (internal/process/next_tick.js:63:19)
[HTTP] <-- POST /wd/hub/session 500 5 ms - 738
[HTTP]

我的测试

public class AndroidTestCaseExample {

    public AndroidDriver driver;

    @BeforeTest
    public void setup() throws MalformedURLException {
        DesiredCapabilities capabilities = new DesiredCapabilities();
        capabilities.setCapability(MobileCapabilityType.PLATFORM_VERSION, "7.0");
        capabilities.setCapability(MobileCapabilityType.PLATFORM_NAME, "Android");
        capabilities.setCapability(MobileCapabilityType.APPIUM_VERSION, "1.11.1");
        capabilities.setCapability(MobileCapabilityType.DEVICE_NAME, "ZX1G22GRHD");
        capabilities.setCapability(MobileCapabilityType.AUTOMATION_NAME,"UiAutomator2");
        capabilities.setCapability(MobileCapabilityType.APPLICATION_NAME, "Absolute");
        driver = new AndroidDriver(new URL("http://127.0.0.1:4723/wd/hub"), capabilities);
    }

    @Test
    public void loadApp() {
        List<MobileElement> elements = (List<MobileElement>)
                driver.findElementByClassName("android.widget.EditText");

        for (MobileElement element : elements) {
            System.out.println(element.toJson());
        }
    }
}

什么Either JSONWP or W3C capabilities should be provided意思


问题答案:

ApplicationName > Absolute替换为 App 或( appPackage
appActivity

//Either add following line in the DesiredCapabilities
capabilities.setCapability(MobileCapabilityType.App, "Path to your apk file");

//OR add following two capabilities if the app is already installed in the testing device
capabilities.setCapability("appPackage", "app package name");
capabilities.setCapability("appActivity, "app activity name");


 类似资料:
  • org.openqa.selenium.SessionNotCreatedException:无法创建新会话。(原始错误:命令失败:C:\Windows\system32\cmd.exe/s/C“C:\Program Files(x86)\Android\Android sdk\platform tools\adb.exe”-s 69c7aa170104安装“C:\Program Files(x8

  • 问题内容: 我是JSF的新手,正在构建使用Facelets创建的应用程序。 这是我的模板 master.xhtml MasterSearch.xhtml MasterSearch.java这是一个bean faces-config.xml 现在,当我运行此代码(实际上是masterp.xhtml)时,它显示出完美的输出并加载了Accuratley,但它在控制台中引发了异常,即 而且我认为由于这个原

  • 问题内容: 我正在尝试使用hibernate模式创建项目,但如果删除该行,则在create所在行中有异常- 项目将成功运行。我正在寻找解决方案,我阅读了这篇文章,并添加了依赖性,但这并不能解决问题 行是: 等于代码中的行: 依存关系 问题答案: 从Hibernate v3.6起,注释类已合并到核心中。您已经指定了对非常旧的注释jar的依赖关系,而该注释jar无法使用Hibernate core 5

  • 我正在学习Appium,我无法使用以下功能创建远程会话。虽然>功能在模拟设备上的Appium server本身中工作 线程“main”org.openqa.selenium.sessionNotCreatedException中出现异常:无法创建新的远程会话。原始错误:127.0.0.0.1生成信息:版本:“3.141.59”,修订版:“E82BE7D358”,时间:“2018-11-14T08:

  • 当我尝试运行测试时,我得到这个错误。 sessionNotCreatedException:无法创建新的远程会话。所需功能=功能[{PlatformName=Android,DeviceName=F4AZFG07P508}],所需功能=功能[{}]生成信息:版本:“3.3.1”,修订版:“5234B325D5”,时间:“2017-03-10 09:10:29+0000”系统信息:主机:“MacBo

  • 当会话仅是一个未来的且还没有被建立的会话时被认为是“新”的。因为 HTTP是一种基于请求-响应的协议,直到客户端“加入”到 HTTP 会话之前它都被认为是新的。当会话跟踪信息返回到服务器指示会话已经建立时客户端加入到会话。直到客户端加入到会话,否则不能假定下一个来自客户端的请求被识别为同一会话。 如果以下之一是 true,会话被认为是“新”的: 客户端还不知道会话 客户端选择不加入会话。 这些条件