protractor fails to switch to iframe

Created on 11 Oct 2017  ·  3Comments  ·  Source: angular/protractor

  • Node Version: node --version v6.11.3
  • Protractor Version: Version 5.1.2
  • Browser(s): chrome
  • Operating System and Version win10
  1. run it from console:
    console

test.spec.js

describe('Suite: test', function () {

    describe('should select iframe', function () {

        beforeAll(function () {
            browser.ignoreSynchronization = true;
            browser.get('https://www.ammado.com/donate');
        });

        afterAll(function () {
            browser.ignoreSynchronization = false;
        });

        it('should wait for iframe', function () {
            waitForEl($('iframe'));
        });

        it('should switch to iframe', function () {
            browser.switchTo().frame(element(by.tagName('iframe')));
        });

        it('should log', function () {
            console.log('iframe selected!')
        });

    });

    function waitForEl(element) {
        var EC = protractor.ExpectedConditions;
        browser.driver.wait(EC.presenceOf(element), 30000).then(function () {
            // success
        }, function (error) {
            fail("waitForEl: " + error + " on element: " + element.locator());
        });
    };

});

conf

exports.config = {
    directConnect: true,

    capabilities: {
        browserName: 'chrome',
        chromeOptions: {
            'args': ['disable-infobars=true'],
            'prefs': {
                'credentials_enable_service': false
            }
        },
    },

    framework: 'jasmine',

    suites: {
        eval: ['./test.spec.js']
    },

    allScriptsTimeout: 30000,

    jasmineNodeOpts: {
        showColors: true,
        defaultTimeoutInterval: 30000,
        isVerbose: true
    },

    onPrepare: function() {
        const SpecReporter = require('jasmine-spec-reporter').SpecReporter;
        jasmine.getEnv().addReporter(new SpecReporter());
        browser.driver.manage().window().setSize(1440, 900);
    },

};

Most helpful comment

browser.switchTo().frame(0) -- is the solution for me if anyone has a similar problem !

All 3 comments

D:\ammado\github\Protractor.Widget\exc>webdriver-manager status
[09:42:35] I/status - selenium standalone versions available: 3.5.3, 3.6.0 [last]
[09:42:35] I/status - chromedriver versions available: 2.32, 2.33 [last]
[09:42:35] I/status - geckodriver version available: v0.19.0 [last]
[09:42:35] I/status - IEDriverServer is not present
[09:42:35] I/status - android-sdk is not present
[09:42:35] I/status - appium is not present

Hi there!

Your question is better suited for StackOverflow or Gitter. Please ask a question there with the 'protractor' tag or post in the Gitter Channel to get help.

From the the getting help section of the README:

Please ask usage and debugging questions on StackOverflow (use the "protractor" tag) or in the Angular discussion group. (Please do not ask support questions here on Github.)

Thanks!

browser.switchTo().frame(0) -- is the solution for me if anyone has a similar problem !

Was this page helpful?
0 / 5 - 0 ratings

Related issues

nt3rp picture nt3rp  ·  3Comments

vishalshivnath picture vishalshivnath  ·  3Comments

amedvedjev picture amedvedjev  ·  3Comments

jmcollin78 picture jmcollin78  ·  3Comments

gamecheck80 picture gamecheck80  ·  3Comments