Selenium: Replace nodemw with mwbot
[lhc/web/wiklou.git] / tests / selenium / pageobjects / delete.page.js
1 'use strict';
2 const Page = require( './page' );
3
4 class DeletePage extends Page {
5
6 get reason() { return browser.element( '#wpReason' ); }
7 get watch() { return browser.element( '#wpWatch' ); }
8 get submit() { return browser.element( '#wpConfirmB' ); }
9 get displayedContent() { return browser.element( '#mw-content-text' ); }
10
11 open( name ) {
12 super.open( name + '&action=delete' );
13 }
14
15 delete( name, reason ) {
16 this.open( name );
17 this.reason.setValue( reason );
18 this.submit.click();
19 }
20
21 apiDelete( name, reason ) {
22
23 const MWBot = require( 'mwbot' ), // https://github.com/Fannon/mwbot
24 Promise = require( 'bluebird' );
25 let bot = new MWBot();
26
27 return Promise.coroutine( function* () {
28 yield bot.loginGetEditToken( {
29 apiUrl: `${browser.options.baseUrl}/api.php`,
30 username: browser.options.username,
31 password: browser.options.password
32 } );
33 yield bot.delete( name, reason );
34 } ).call( this );
35
36 }
37
38 }
39 module.exports = new DeletePage();