量角器 - 特殊情况下框架的极其奇怪的行为

时间:2015-10-15 10:24:42

标签: javascript intellij-idea selenium-webdriver protractor e2e-testing

这是我的规范:

var UsersPage = require('../pages/users_page.js');
var UserDetailsPage = require('../pages/user_details_page.js');
var WelcomePage = require('../pages/welcome_page.js');
var LogIn = require('../helper.methods/authentication');

describe('Test -> test', function () {

    var EC = protractor.ExpectedConditions;
    var WAIT_TIMEOUT = 10000;

    beforeEach(function () {
        LogIn.asAdmin();
        var welcomePage = new WelcomePage();
        browser.wait(EC.elementToBeClickable(welcomePage.usersButton), WAIT_TIMEOUT, 'users tab did not become clickable');
        clickWithWait(welcomePage.usersButton);
    });

    afterEach(function () {
        var welcomePage = new WelcomePage();
        clickWithWait(welcomePage.loginButton);
        clickWithWait(welcomePage.logoutButton);
    });

    function expectVisibilityOf(element, message) {
        return browser.wait(EC.visibilityOf(element), WAIT_TIMEOUT, message);
    }

    it('verifies login validation and log in by newly added account', function () {
        var userDetailsPage = new UserDetailsPage();
        var usersPage = new UsersPage();
        expectVisibilityOf(usersPage.firstRow, 'element firstRow was not visible ');
        clickWithWait(usersPage.testUser);
        clickWithWait(userDetailsPage.addAccountButton);
        dv.sleep(500);
        clickWithWait(userDetailsPage.chooseDomainButton);
        clickWithWait(userDetailsPage.firstAvailableDomainFromList);
        clickWithWait(userDetailsPage.loginInputField);
        expectVisibilityOf(userDetailsPage.userLoginOfFirstAccount, 'element userLoginOfFirstAccount was not visible ');
        var busyLogin = userDetailsPage.userLoginOfFirstAccount.getText();
        setValueOfElement(userDetailsPage.loginInputField, Math.random().toString(36).substr(2, 5));
        browser.wait(EC.textToBePresentInElement(userDetailsPage.loginLabelElement, 'Login is too short'), 5000, 'element loginLabelElement not contain: Login is too short');
        userDetailsPage.loginInputField.clear();
        setValueOfElement(userDetailsPage.loginInputField, busyLogin);
        browser.wait(EC.textToBePresentInElement(userDetailsPage.loginLabelElement, 'Login is already taken'), 5000, 'element loginLabelElement not contain: Login is already taken');
        userDetailsPage.loginInputField.clear();
        var userLogin = Math.random().toString(36).substr(2, 20);
        setValueOfElement(userDetailsPage.loginInputField, userLogin);
        browser.wait(EC.textToBePresentInElement(userDetailsPage.loginLabelElement, 'Login is available'), 5000, 'element loginLabelElement not contain: Login is available');
        browser.wait(EC.elementToBeClickable(userDetailsPage.saveAccountButton), WAIT_TIMEOUT, 'element saveAccountButton was not clickable ');
        clickWithWait(userDetailsPage.saveAccountButton);
               });

问题非常奇怪,因为测试流程在我的同事计算机上运行正常(使用Linux),但我的(Mac OS)甚至没有启动(只执行beforeEachafterEach)。我在Chrome中运行它,在Intellij中进行调试。 尝试在Intellij中无效/重新启动缓存,重新启动计算机等,但它没有帮助。我认为这可能是编译器的一些问题导致本地对硒网格问题是相同的。

此外 - 最有趣的是 - 当我删除最后一行测试(clickWithWait(userDetailsPage.saveAccountButton);)时,测试流程正常!

它让我大脑爆炸,因为没有人知道发生了什么。任何人都可以提出建议吗?

在快速快捷方式中(再次) - 测试工作正常,行clickWithWait(userDetailsPage.saveAccountButton);已注释但在取消注释(imo)后,只有BeforeEachAfterEach完成,甚至没有点击{{1元素。

函数usersPage.testuser的实现如下(有必要使用它来避免clickOnElementWithWait):

StaleElementReferenceException

函数clickOnElementWithWait = function (element, attempts) { if (attempts == null) { attempts = 10; } return element.click().then(function (found) { }, function (err) { if (attempts > 0) { browser.sleep(100); return exports.clickOnElementWithWait(element, attempts - 1); } else { throw err; } }); }; 的实现如下(有必要使用它来避免setValueOfElement):

StaleElementReferenceException

0 个答案:

没有答案