3

I have the problems with clicking the anchors using the instance of browser that Protractor invokes. As I'm dealing with the mobile resolution I use the Chrome driver emulator.

"browserName": "chrome",
"chromeOptions": {
    "mobileEmulation": {
        "deviceName": 'Apple iPhone 5'
    }
}

Example of the anchor:

<a href="javascript:;" id="FooterContent_NavigationBarCTRL_LoginLink" class="login noroute GA_loginIntention tappable">Login</a>

When I pause the test and try to click in the same browser manually it doesn't work. However if I have an "ordinary" instance of Chrome everything works, I can click any links. When I click the link page just jumps to the top instead of going to the next page.

I tryed a work-around using browser.executeScript("") and it solved the issue for some cases when divs are hidden, for instance. In this particular case it doesn't seem to work as I suppose to navigate to the next page.

Protractor version: 3.3.0.
selenium-server-standalone-2.52.0
chromedriver_2.21

Package.json-file:

"version": "0.1.0",
  "devDependencies": {
    "gulp": "^3.9.1",
    "gulp-typescript": "2.11.0",
    "gulp-debug": "^2.1.2",
    "async": "^1.4.2",
    "glob": "^6.0.1",
    "http-backend-proxy": "^1.4.2",
    "jasmine-spec-reporter": "^2.4.0",
    "mkdirp": "^0.5.0",
    "moment": "^2.10.6",
    "nodemailer": "^1.3.2",
    "nodemailer-smtp-pool": "^1.0.1",
    "nodemailer-smtp-transport": "^1.0.2",
    "protractor": "^3.0.0",
    "protractor-html-screenshot-reporter": "^0.0.21",
    "protractor-jasmine2-screenshot-reporter": "^0.3.0",
    "q": "^1.2.0",
    "request": "^2.53.0",
    "require-new": "^1.1.0",
      "require-dir": "^0.3.0",
    "underscore": "^1.7.0",
    "xoauth2": "^1.0.0"   

Page-object shared.ts:

import coreHelper = require("../../page-objects/common/core");
import startpage = require("../../page-objects/startpage/startpage.po");

export class Login {
    username: protractor.ElementFinder = element(by.css("#usernameTB"));
    password: protractor.ElementFinder = element(by.css("#passwordTB"));
    button: protractor.ElementFinder = element(by.css(".loginBTN"));
}

export class Menu {
    menuLink: protractor.ElementFinder = element(by.css("a[id*='_MenuLink']"));
    loginLink: protractor.ElementFinder = element(by.css("a[id*='_LoginLink']"));
    accountMoney: protractor.ElementFinder = element(by.css("#navigationbar > div > span"));
}

export class Submenu {
    logout: protractor.ElementFinder = element(by.css("#scrollerInside > section.menu.MobileCore.active.menu_mainmenu > div > header > button.discreet.logout.noroute"));
    loginLink: protractor.ElementFinder = element(by.css("_BonusRoute"));
}

export class Shared {
    core = new coreHelper.Core();
    browser: any;
    private po = new startpage.Startpage();
    private loginPage = new Login();
    private menu = new Menu();
    private submenu = new Submenu();
    private modal = new Modal();
    gameLogin = new GameLogin();

    loginLinkClick(): webdriver.promise.Promise<void> {
        return (this.menu.loginLink).click();
    }

    login(): webdriver.promise.Promise<void> {
        return this.core.waitForDisplayOf(this.menu.loginLink).then(() => {
            this.loginLinkClick()
                .then(() => { return this.core.waitForDisplayOf(this.loginPage.username); })
                .then(() => {
                    var username = this.loginPage.username;
                    var password = this.loginPage.password;
                    var button = this.loginPage.button;

                    username.clear();
                    password.clear();

                    return username.sendKeys(browser.params.bets10Login)
                        .then(() => { return password.sendKeys(browser.params.bets10Password); })
                        .then(() => { return button.click(); })
                        .then(() => { return this.core.waitForInvisibilityOf(this.loginPage.username); });
                });
        });
    }

}

The testspec.ts file:

import sharedHelper = require("../../page-objects/common/shared.po");
import startpageHelper = require("../../page-objects/startpage/startpage.po");

var shared = new sharedHelper.Shared();
var startpage = new startpageHelper.Startpage();

describe("Startpage: ", () => {
    beforeEach(() => {
        shared.openStartpage();
    });

    describe("when clicking the Casino button on startpage", () => {
        it("then a lobby window opens", () => {
            startpage.casinoIconClick().then(() => {
                expect(browser.driver.getCurrentUrl()).toMatch(browser.params.casinoUrl);
            });
        });
    });

    });
});

It worth to add that it worked for about 1 months ago. When I went thought with developers everything that could be possibly changed, we couldn't recall any things that could lead to this behaviour.

What can be the issue of my problem?

Aya
  • 31
  • 3
  • May be those answers can help you : http://stackoverflow.com/questions/36871071/click-function-isnt-working-in-protractor-scripts – Emna Ayadi May 17 '16 at 14:29
  • put the code for your testspec.js – Emna Ayadi May 17 '16 at 14:32
  • Emna, I updated my question with testspec-file. Those answers didn't help me that much as they don't directly answer on my question why can't I click manually. – Aya May 17 '16 at 14:40
  • My apologies for messing up with a code. I added now easier example of the case when it doesn't work. – Aya May 17 '16 at 14:55
  • No problem or that :) sorry for my question i didn't use it before what is the role of Page-object shared.ts and Package.json-file ? – Emna Ayadi May 17 '16 at 15:39
  • I suggest that as first try try a simple example without complicating it :) – Emna Ayadi May 17 '16 at 15:40
  • 1
    I can absolutely start all over and make it simple. But it worked once upon a time so I wonder if someone was experiencing same problem :) – Aya May 18 '16 at 07:47
  • good luck, sorry i didn't use some thing like you example :) – Emna Ayadi May 18 '16 at 07:48
  • Page-objects help you to keep your tests clean from logic. Package.js describes the package and it's related dependencies. – Aya May 18 '16 at 07:50

0 Answers0