vendredi 12 août 2016

How to set webdriver element variable as value

My Mocha test passes until I try to set a form value with a variable (eventNameRandom) as so:

it('can confirm an event when various users join @watch', function (done) {
var randomNumber = Math.random();
var eventNameRandom = 'London event' + randomNumber;

//other commands, e.g. browser.url...

browser.setValue( '[name="name"]', eventNameRandom );

browser.click('[class="confirm"]')
        .pause(1400);

Setting the variables themselves is not the problem, it seems, as it passes again when I change it to:

browser.setValue( '[name="name"]', 'eventNameRandom' );

Somewhat oddly, the error is:

Uncaught AssertionError: expected 'Event: (Unconfirmed)' to include '(Confirmed)'

which relates to a test section some way down:

var eventListing = browser.getText('.event-listing');
expect(eventListing).to.include( '(Confirmed)' );

...but by elimination, it seems to be the variable setting described above which actually breaks the test. Any ideas?

Aucun commentaire:

Enregistrer un commentaire