LoginSignup
0
0

More than 5 years have passed since last update.

非 Angular.js サイトでも Protractor でテスト

Last updated at Posted at 2014-12-28

Protractor は Angular.js 専用というわけではなく、Angular.js を使っていないサイトでも使用することができました。ポイントは browser.ignoreSynchronization = true を設定するのと、要素の選択に findElement を使うところです。

WordPress プラグインの管理画面のテストをするために以下の様なコードを使ってます。beforeEach は Jasmine の仕組みで、ここにテストの準備のために実行するコードを書きます。

describe('SWE setting screen', function() {
    it('WP login', function() {
        browser.get('http://localhost/wp-login.php');

        browser.findElement(By.id('user_login')).sendKeys('admin');
        browser.findElement(By.id('user_pass')).sendKeys('password');
        browser.findElement(By.id('wp-submit')).click();

        expect(browser.getTitle()).toMatch(/^Dashboard/);
    });
});

beforeEach(function() {
    browser.ignoreSynchronization = true;
});

簡単ですが、Protractor でテストを書き始めることができた記念ということで。

参考: Protractor - Testing Angular and Non Angular Sites

0
0
0

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
0
0