0

I couldn't find much information or useful examples to understand how this method works on a Javascript UI testing framework. I have the following element which is returned in an array:

console.log(elementarray[0]);

{ ELEMENT: '25',
  'element-6066-11e4-a52e-4f735466cecf': '25',
  selector: '[data="abc"]',
  value: { ELEMENT: '25' },
  index: 0 }

however when I run:

browser.elementIdText(elementarray[0].ELEMENT)

I see this:

{ state: 'success',
  sessionId: 'af7ef2fb-7d1d-456e-ad14-c5c1fd9d83c2',
  hCode: 1013623656,
  value: '17:55',
  class: 'org.openqa.selenium.remote.Response',
  _status: 0 }

How exactly is browser.elementIdText working here, can anyone provide a simple explanation with an example pls. I see information here that I am not seeing when I log the first item in the array and surely the value of elementarray[0].ELEMENT is just 25 right? as it's shown in the first property of the object?

Thanks for any useful replies.

j obe
  • 1,759
  • 4
  • 15
  • 23

1 Answers1

1

elementIdText expect ID as argument. In order to get ID, you need to use allElem.value[0].ELEMENT for example. See below code.

describe('allx', () => {

it('allx', () => {

  browser.url("https://the-internet.herokuapp.com/");
  allElem=browser.elements('//div[2]/div/ul/li/a');
  console.log(allElem.value[0].ELEMENT)
  text=browser.elementIdText(allElem.value[0].ELEMENT).value;
  console.log(text);
 });
});
  • Can you just break this down a little please, so allElem becomes a collection of every div and ul, li and a element on the page? I see that this returns 38 elements. The value property on these elements says [object], so how is this accessed and what is the ELEMENT property of this value object? – j obe Nov 06 '18 at 10:38
  • I mean I see what you're doing, can you just explain what's happening at the different points, thanks. – j obe Nov 06 '18 at 10:39
  • Still need help with this @jobe? – iamdanchiv Jan 26 '19 at 07:07
  • @iamdanchiv Sure if you can add anything to help. – j obe Feb 02 '19 at 15:11