protractor icon indicating copy to clipboard operation
protractor copied to clipboard

java.lang.IllegalStateException: Expected BEGIN_OBJECT but was STRING at line 1 column 1 path $

Open arjunUnniumbath opened this issue 8 years ago • 10 comments

hi guys,

I'm trying to work with IE, after setting up the path of driver file in jvmargs. Config js

`exports.config = {

capabilities: { 'browserName': 'internet explorer', 'version':'11', 'platform':'Any', 'ignoreProtectedModeSettings': true },

// Framework to use. Jasmine is recommended.
framework: 'jasmine',
specs: ['sample.js'],
SELENIUM_PROMISE_MANAGER: false,
localSeleniumStandaloneOpts: {
  jvmArgs: [
    '-Dwebdriver.ie.driver=./node_modules/protractor/node_modules/webdriver-manager/selenium/IEDriverServer3.12.0.exe'
  ]
},

onPrepare: function() {
  var width = 1600;
  var height = 1200;
  browser.driver.manage().window().setSize(width, height);

},

jasmineNodeOpts: {
  defaultTimeoutInterval: 600000
}

};`

I'm getting the error while executing:

`C:\Users\ARjun_u\Desktop\E2E\repo>run.bat

C:\Users\ARjun_u\Desktop\E2E\repo>protractor config.js (node:14976) [DEP0022] DeprecationWarning: os.tmpDir() is deprecated. Use os.tmpdir() instead. [16:32:05] I/launcher - Running 1 instances of WebDriver [16:32:05] I/local - Starting selenium standalone server... [16:32:20] I/local - Selenium standalone server started at http://10.82.20.41:6564/wd/hub Started FFF

Failures:

  1. angularjs homepage should greet the named user Message: Failed: java.lang.IllegalStateException: Expected BEGIN_OBJECT but was STRING at line 1 column 1 path $ Build info: version: '3.12.0', revision: '7c6e0b3', time: '2018-05-08T15:15:08.936Z' System info: host: 'MYSHEC126942L', ip: '10.82.20.41', os.name: 'Windows 8.1', os.arch: 'amd64', os.version: '6.3', java.version: '1.8.0_171' Driver info: driver.version: unknown Stack: WebDriverError: java.lang.IllegalStateException: Expected BEGIN_OBJECT but was STRING at line 1 column 1 path $ Build info: version: '3.12.0', revision: '7c6e0b3', time: '2018-05-08T15:15:08.936Z' System info: host: 'MYSHEC126942L', ip: '10.82.20.41', os.name: 'Windows 8.1', os.arch: 'amd64', os.version: '6.3', java.version: '1.8.0_171' Driver info: driver.version: unknown at Object.checkLegacyResponse (C:\Users\ARjun_u\AppData\Roaming\npm\node_modules\protractor\node_modules\selenium-webdriver\lib\error.js:546:15) at parseHttpResponse (C:\Users\ARjun_u\AppData\Roaming\npm\node_modules\protractor\node_modules\selenium-webdriver\lib\http.js:509:13) at doSend.then.response (C:\Users\ARjun_u\AppData\Roaming\npm\node_modules\protractor\node_modules\selenium-webdriver\lib\http.js:441:30) at at process._tickCallback (internal/process/next_tick.js:188:7) From asynchronous test: Error at Suite. (C:\Users\ARjun_u\Desktop\E2E\repo\sample.js:3:3) at Object. (C:\Users\ARjun_u\Desktop\E2E\repo\sample.js:1:63) at Module._compile (module.js:652:30) at Object.Module._extensions..js (module.js:663:10) at Module.load (module.js:565:32) at tryModuleLoad (module.js:505:12)`

arjunUnniumbath avatar May 28 '18 13:05 arjunUnniumbath

@IgorSasovets

arjunUnniumbath avatar May 29 '18 05:05 arjunUnniumbath

Hi, @arjunUnniumbath ! Did you try to use directConnect option instead of localSeleniumStandaloneOpts?

IgorSasovets avatar Jun 05 '18 13:06 IgorSasovets

@IgorSasovets : I wanted to use IE instead of Chrome and firefox.

arjunUnniumbath avatar Jun 05 '18 15:06 arjunUnniumbath

@arjunUnniumbath , if I provide example of tests for IE (v.10) it'll be suitable for you?

IgorSasovets avatar Jun 06 '18 20:06 IgorSasovets

@IgorSasovets : I can try.

arjunUnniumbath avatar Jun 07 '18 08:06 arjunUnniumbath

Hi, @arjunUnniumbath ! Please take a look at this article. Hope it will help you!

IgorSasovets avatar Jun 10 '18 20:06 IgorSasovets

@IgorSasovets : I had followed instructions from the same webpage while creating my script.

arjunUnniumbath avatar Jun 13 '18 07:06 arjunUnniumbath

I did the same and all working as expected, can provide example project if needed

IgorSasovets avatar Jun 13 '18 08:06 IgorSasovets

@IgorSasovets : Sure.. I can try that out in my slave machine. Can you share the versions which your are using.

arjunUnniumbath avatar Jun 13 '18 12:06 arjunUnniumbath

Here is config.js

exports.config = {
  //directConnect: true,
  //TO RUN UNDER IE MANUALLY LAUNCH DRIVER IN node_modules\protractor\node_modules\selenium\<ie_driver>
  seleniumAddress: 'http://localhost:5555',
  capabilities: {
    browserName: 'internet explorer',
    ignoreProtectedModeSettings: true,
    platform: 'ANY'
  },
  //seleniumArgs: ['-Dwebdriver.ie.driver=node_modules/protractor/selenium/IEDriverServer.exe'],
  localSeleniumStandaloneOpts: {
    jvmArgs: [
      '-Dwebdriver.ie.driver=./node_modules/protractor/node_modules/webdriver-manager/selenium/IEDriverServer3.12.0.exe'
    ]
  },
  specs: [
    'open-page-test.js'
  ],
  params: {
    pageUrl: 'https://www.dice.com/employer/login'
  }
}

open-page-test.js

'use strict';
const params = browser.params;

describe('Load page test', () => {
  beforeEach(() => {
      return browser.get(params.pageUrl);
  });
  describe('Confirm ability to open page fast', () => {
    it('Should successfully open page and fill data fields', function() {
      const userNameField = $('#userName');
      const passwordField = $('#password');
      const signInButton = $('.btn.dice-btn.sign-in-btn');
      const incorectDataMessage = $('.text-danger');
      return browser.wait(protractor.ExpectedConditions.visibilityOf(userNameField), 5000)
        .then(() => userNameField.sendKeys('John'))
        .then(() => passwordField.sendKeys('Smith'))
	.then(() => signInButton.click())
        .then(() => {
            expect(incorectDataMessage.isDisplayed()).toBe(true);
        });
      });
  });
});

package.json

{
  "name": "get-config-capabilities",
  "version": "1.0.0",
  "description": "This is example of test that contains config capabilities data.",
  "main": "config.js",
  "scripts": {
    "test": "echo \"Error: no test specified\" && exit 1"
  },
  "keywords": [
    "protractor",
    "capabilities",
    "config"
  ],
  "author": "Igor Sasovets",
  "license": "ISC",
  "devDependencies": {
    "chai": "^4.1.2",
    "chai-as-promised": "^7.1.1",
    "protractor": "^5.3.0",
    "protractor-firefox-support": "^1.1.0"
  }
}

At first, install IE driver using node_modules\protractor\bin\webdriver-manager update --ie command, start *.exe file manually and then run tests.

image

image

IgorSasovets avatar Jun 13 '18 18:06 IgorSasovets