用实习生在safari ios上运行Appium

时间:2017-01-27 16:33:13

标签: javascript ios intern

 public void beforeTest() throws MalformedURLException { //set capabilities required
        DesiredCapabilities capabilities = new DesiredCapabilities();
        capabilities.setCapability("deviceName", "iPhone 6");
        capabilities.setCapability("platformName", "iOS");
        capabilities.setCapability("platformVersion", "8.1");
        capabilities.setCapability(CapabilityType.BROWSER_NAME, "safari");
        wd = new IOSDriver(new URL("http://127.0.0.1:4723/wd/hub"), capabilities);//instantiate driver
        wd.manage().timeouts().implicitlyWait( 30,TimeUnit.SECONDS);
    }

如何使用javascript编写此代码以在intern.js上使用它?

2 个答案:

答案 0 :(得分:0)

您是否尝试过安装并遵循Intern的教程?

无论如何,功能在配置文件中设置(查看https://github.com/theintern/intern/blob/master/tests/example.intern.js中的示例)

Webdrivers - 看看https://theintern.github.io/intern/#local-selenium。您也可以使用云托管(https://theintern.github.io/intern/#hosted-selenium)或SeleniumGrid运行测试(https://theintern.github.io/intern/#selenium-grid

关于implicitWait,请使用https://theintern.github.io/leadfoot/module-leadfoot_Command.html#setFindTimeout

环境配置示例:

配置示例:

const W_KEY = 119;
const A_KEY = 97;
const S_KEY = 115;
const D_KEY = 100;

document.body.addEventListener("keypress", function(e) {
  let entry = null;

  switch(e.keyCode) {
    case W_KEY:
      entry = "w";
      break;
    case A_KEY:
      entry = "a";
      break;
    case S_KEY:
      entry = "s";
      break;
    case D_KEY:
      entry = "d";
      break;
  }

  if(entry) {
    console.log("Key " + entry + " was pressed!");

    AJRover.move(key);
  }

}

答案 1 :(得分:0)

尝试在intern.js上设置功能:

    capabilities: {
        appiumVersion: '1.0',
        platformName: 'iOS',
        platformVersion: '8.1',
        deviceName: 'iPhone 6',
        browserName: 'safari'

},

使用iOS模拟器配置环境运行测试:

environments: [
    {
        simulator: true,
        fixSessionCapabilities: false,

}
].

要使用Intern测试移动Web应用程序,请先手动启动Appium服务器。然后开始测试跑步者。