Debian Codegraph @

tests/selenium/docs/Page_object_pattern/specs/login.js

raw symbols SCIP
1 // Example code for Selenium/Explanation/Page object pattern
2 // https://www.mediawiki.org/wiki/Selenium/Explanation/Page_object_pattern
3
4 'use strict';
5
6 const Api = require( 'wdio-mediawiki/Api' );
7 const Util = require( 'wdio-mediawiki/Util' );
8
9 // baseUrl is required for our continuous integration.
10 // If you don't have MW_SERVER and MW_SCRIPT_PATH environment variables set
11 // you can probably hardcode it to something like this:
12 // const baseUrl = 'http://localhost:8080/wiki/';
13 const baseUrl = `${ process.env.MW_SERVER }${ process.env.MW_SCRIPT_PATH }/index.php?title=`;
14
15 describe( 'User', () => {
16 let password, username, bot;
17
18 before( async () => {
19 bot = await Api.bot();
20 } );
21
22 beforeEach( async () => {
23 username = Util.getTestString( 'User-' );
24 password = Util.getTestString();
25 } );
26
27 it( 'should be able to log in without page object', async () => {
28 // create
29 await Api.createAccount( bot, username, password );
30
31 // log in
32 await browser.url( `${ baseUrl }Special:UserLogin` );
33 await $( '#wpName1' ).setValue( username );
34 await $( '#wpPassword1' ).setValue( password );
35 await $( '#wpLoginAttempt' ).click();
36
37 // check
38 const actualUsername = await browser.execute( () => mw.config.get( 'wgUserName' ) );
39 expect( actualUsername ).toBe( username );
40 } );
41 } );