Cannot run protractor scripts using code generated by Appium for IOS it says that findelement is not a function

穿精又带淫゛_ 提交于 2019-12-11 01:06:45

问题


I want to automate my tests for an Angular JS site using Ipad Air simulator, appium and protractor but the problem that i'm not able to run correctly the script.

This is my config file

​exports.config = {
  allScriptsTimeout: 600000,
  seleniumAddress: 'http://0.0.0.0:4723/wd/hub',

  specs: [
    'testsuite/test3.js'
  ],

  capabilities: {
    browserName: 'safari',
   'appium-version': '1.4.13',
    platformName: 'iOS',
    platformVersion: '9.3',
    deviceName: 'iPad Air'
},

  chromeOnly: false,

  baseUrl: 'http://10.0.22.82:4180/jws/fetablet_dev_T1000',

  frameworks:[
    'mocha',
    'chai'
  ],

mochaOpts: { 

    defaultTimeoutInterval:1000000
}         
};   

My test3.js file contain :

"use strict";
var wd = require("wd");
var chai = require("chai");
var chaiAsPromised = require("chai-as-promised");

chai.use(chaiAsPromised);

var expect = chai.expect;

chai.should();
chaiAsPromised.transferPromiseness = wd.transferPromiseness;

describe('my app', function() {

it('should make the login test',function()  {

var desired = {
browserName: 'safari',
platformName:'iOS',
name:"This is an example for login test"
}

browser.get("0.22.82:4180/jws/fetablet_dev_T1000");


 browser.driver.findelement(by.xpath("//UIAApplication[1]/UIAWindow[2]/UIAScrollView[1]/UIAScrollView[1]/UIAWebView[1]/UIATextField[1]")).sendKeys("RET02");


});

});

While running protractor.config.js i have the following error and my test is failed, how can i identify elements?

​Using the selenium server at http://0.0.0.0:4723/wd/hub
[launcher] Running 1 instances of WebDriver
Started
F

Failures:​​
1) my app should make the login test
  Message:
    Failed: browser.driver.findelement is not a function
  Stack:
    TypeError: browser.driver.findelement is not a function
        at Object.<anonymous> (/Users/qaquod/Development/qa/qa_fetablet/testsuite/test3.js:26:17)
        at /usr/local/lib/node_modules/protractor/node_modules/jasminewd2/index.js:96:23
        at new Promise (/usr/local/lib/node_modules/protractor/node_modules/selenium-webdriver/lib/promise.js:1043:7)
        at controlFlowExecute (/usr/local/lib/node_modules/protractor/node_modules/jasminewd2/index.js:82:18)
        at TaskQueue.execute_ (/usr/local/lib/node_modules/protractor/node_modules/selenium-webdriver/lib/promise.js:2790:14)
        at TaskQueue.executeNext_ (/usr/local/lib/node_modules/protractor/node_modules/selenium-webdriver/lib/promise.js:2773:21)
        at /usr/local/lib/node_modules/protractor/node_modules/selenium-webdriver/lib/promise.js:2697:25
        at /usr/local/lib/node_modules/protractor/node_modules/selenium-webdriver/lib/promise.js:639:7
        at process._tickCallback (internal/process/next_tick.js:103:7)
    From: Task: Run it("should make the login test") in control flow
        at Object.<anonymous> (/usr/local/lib/node_modules/protractor/node_modules/jasminewd2/index.js:81:14)
    From asynchronous test: 
    Error
        at Suite.<anonymous> (/Users/qaquod/Development/qa/qa_fetablet/testsuite/test3.js:15:1)
        at Object.<anonymous> (/Users/qaquod/Development/qa/qa_fetablet/testsuite/test3.js:13:1)
        at Module._compile (module.js:413:34)
        at Object.Module._extensions..js (module.js:422:10)
        at Module.load (module.js:357:32)
        at Function.Module._load (module.js:314:12)
1 spec, 1 failure
Finished in 0.03 seconds
[launcher] 0 instance(s) of WebDriver still running
​
[launcher] safari #01 failed 1 test(s)
[launcher] overall: 1 failed spec(s)
[launcher] Process exited with error code​ 1​

回答1:


You might probably want to change this for sure :

browser.driver.findelement(by.xpath("//UIAApplication[1]/UIAWindow[2]/UIAScrollView[1]/UIAScrollView[1]/UIAWebView[1]/UIATextField[1]")).sendKeys("RET02");

to

browser.driver.findElement(by.xpath("//UIAApplication[1]/UIAWindow[2]/UIAScrollView[1]/UIAScrollView[1]/UIAWebView[1]/UIATextField[1]")).sendKeys("RET02");

                   ^ //E instead of e


来源:https://stackoverflow.com/questions/36619518/cannot-run-protractor-scripts-using-code-generated-by-appium-for-ios-it-says-tha

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!