0

I'm trying to reconstruct and run hybrid apps tests by Appium + Protractor using example here My global goal is make a test framework for hybrid/native apps based Appium + Protractor My local goal is understand how to integrate Appium + Protractor and choose a best approaches. But at the start I meet an obstacle to get text from element and compare with expected. I can't to get text from WebView element and compare with expected by default methods elementByXpath.getText();

So, I added a new test to file

it("equal text", function () {
    return driver
        .elementById('buttonStartWebviewCD')
        .click()
        .sleep(5000)
        .contexts()
        .then(function (ctxs) {
            console.log(ctxs);
            return driver.context(ctxs[ctxs.length - 1]);
        })
        .source().then(function (source) {
            source.should.include('Prefered Car');
        })
        .elementById('name_input')
        .clear()
        .sendKeys('Andrey')
        .sendKeys(wd.SPECIAL_KEYS.Return)
        .sleep(2000)
        .elementByXPath("//h2").getText()
        .then(function(text) {
            console.log(text);
        });
});

I found similar situation with my here on stackoverflow but it doesn't help me. Error:

driver.elementById(...).click(...).sleep(...).contexts(...).then(...).source(...).then(...).elementById(...).clear(...).sendKeys(...).sendKeys(...).sleep(...).elementByXPath(...).getText is not a function at Context. (sample-code\examples\node\android- webview.js:152:28) at _fulfilled (sample- code\examples\node\node_modules\wd\node_modules\q\q.js:834:54) at C:\protractor\sample-code\sample- code\examples\node\node_modules\wd\node_modules\q\q.js:863:30 at Promise.promise.promiseDispatch (sample- code\examples\node\node_modules\wd\node_modules\q\q.js:796:13) at C:\protractor\sample-code\sample- code\examples\node\node_modules\wd\node_modules\q\q.js:604:44 at runSingle (sample- code\examples\node\node_modules\wd\node_modules\q\q.js:137:13) at flush (sample- code\examples\node\node_modules\wd\node_modules\q\q.js:125:13) at process._tickCallback (internal/process/next_tick.js:61:11)

Help me to resolve this problem

Andrew
  • 29
  • 11
  • So it looks like the "example here" is not a Protractor example...it uses wd (https://www.npmjs.com/package/wd) – cnishina Jan 31 '19 at 04:43
  • @cnishina I'm not agree with you cause in official Protractor doc (relate with mobile) I found a code example and I used in my case. – Andrew Jan 31 '19 at 15:16

0 Answers0