element.getText().then(function) not being executed

The name of the pictureThe name of the pictureThe name of the pictureClash Royale CLAN TAG#URR8PPP



element.getText().then(function) not being executed



I am working with protractor and cucumber. I want to print the text returned from getText. I am using .then function to obtain such text, but for some reason, console.log code is not being executed.


cucumber


console.log



Why is this happening?


checkDropdown: function (value, dropdown)
let name = element(by.id(dropdown));
name.getText().then(function(text)
console.log(text);
);
expect(name.getText()).to.eventually.equal(value);
,



The protractor.conf.js file is:
Protractor file is:


exports.config =
seleniumAddress: 'http://localhost:4444/wd/hub', // This is targetting your local running instance of the selenium webdriver

specs: [
'../Features/UI_Tests.feature'
],

capabilities:
browserName: 'chrome' // You can use any browser you want. On a CI environment you're going to want to use PhantomJS
,

framework: 'custom', //We need this line to use the cucumber framework

frameworkPath: require.resolve('protractor-cucumber-framework'), // Here it is

cucumberOpts:
//format: 'pretty',
require: '../Features/step_definitions/my_steps.js', // This is where we'll be writing our actual tests
//tags: ['@login','@app'],
strict: true,
plugin:"json"
,
resultJsonOutputFile:'./testResults.json', //output file path to store the final results in .json format
params:
env:
hostname: 'http://0.0.0.0:8000' // Whatever the address of your app is


;



Thanks in advance.





Maybe the promise is rejected?
– undefined
22 hours ago





I do not know, how can I check if it is rejected?
– Alfredo Bazo Lopez
21 hours ago





By using promise.catch.
– undefined
21 hours ago






please show our protractor conf.js
– yong
20 hours ago





You can see my protractor.conf.js file
– Alfredo Bazo Lopez
19 hours ago




1 Answer
1



May be the text value which you log is blank.



Can you try adding some test in front of your text


name.getText().then((text)=>
console.log('Text value is' + text);
);



Just to check if console.log is executed.





I had already done it and nothing happens. I have also debugged the code and the console.log() is not being executed. Thanks for your answer Bharath
– Alfredo Bazo Lopez
20 hours ago






By clicking "Post Your Answer", you acknowledge that you have read our updated terms of service, privacy policy and cookie policy, and that your continued use of the website is subject to these policies.

Popular posts from this blog

Firebase Auth - with Email and Password - Check user already registered

Dynamically update html content plain JS

How to determine optimal route across keyboard