Selenium Webdriverjs test working in chrome but not in phantomjs

65 visualizações
Pular para a primeira mensagem não lida

Naresh Bhatia

não lida,
26 de ago. de 2015, 11:03:2426/08/2015
para phantomjs

I have a very simple form: you enter a first name and a last name, click submit, it displays the full name. I wrote a simple test for this form using Selenium Webdriverjs. It works with chrome, but not with phantomjs. Am I missing any trick to make it work with phantomjs? I am using phantomjs version 2.0.0.

Here's the test code:

var webdriver = require('selenium-webdriver');
var test = require('selenium-webdriver/testing');
var assert = require('assert');

test.describe('Name Form', function() {
    var browser;

    test.beforeEach(function() {
        browser = new webdriver.Builder()
            .forBrowser('phantomjs')
            .build();
    });

    test.afterEach(function() {
        browser.quit();
    });

    test.it('should display the entered name when the Submit button is clicked', function() {
        browser.get('http://localhost:8080');

        browser
            .findElement(webdriver.By.id('firstName'))

            // Fill in first name
            .then(function(firstNameElement) {
                firstNameElement.sendKeys('Naresh');
                return browser.findElement(webdriver.By.id('lastName'));
            })

            // Fill in last name
            .then(function(lastNameElement) {
                lastNameElement.sendKeys('Bhatia');
                return browser.findElement(webdriver.By.id('submitButton'));
            })

            // Click the submit button
            .then(function(submitButton) {
                submitButton.click();
                return browser.findElement(webdriver.By.id('displayName'));
            })

            // Get the full name displayed below the form
            .then(function(displayNameElement) {
                return displayNameElement.getText();
            })

            // Check if the displayed name is what you expected
            .then(function(displayName) {
                assert.equal(displayName, 'Naresh Bhatia');
            });
    });
});

Here's the error:

  Name Form
    1) should display the entered name when the Submit button is clicked


  0 passing (1s)
  1 failing

  1) Name Form should display the entered name when the Submit button is clicked:

      AssertionError: '' == 'Naresh Bhatia'
      + expected - actual

      +Naresh Bhatia

      at test/nameFormTest.js:49:24
      at Array.forEach (native)
  From: Task: Name Form should display the entered name when the Submit button is clicked
      at Array.forEach (native)
Responder a todos
Responder ao autor
Encaminhar
0 nova mensagem