This repository has been archived by the owner on Feb 18, 2021. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 20
/
profile-page.js
executable file
·60 lines (51 loc) · 1.75 KB
/
profile-page.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
/** @format */
import webdriver from 'selenium-webdriver';
import AsyncBaseContainer from '../async-base-container';
import * as driverHelper from '../driver-helper.js';
import * as driverManager from '../driver-manager.js';
const by = webdriver.By;
export default class ProfilePage extends AsyncBaseContainer {
constructor( driver ) {
super( driver, by.css( '.me-profile-settings' ) );
}
async clickSignOut() {
const signOutSelector = by.css( '.me-sidebar__signout-button,.sidebar__me-signout-button' );
await this._closeProfileViewOnMobile();
await driverHelper.clickWhenClickable( this.driver, signOutSelector );
return driverHelper.waitTillNotPresent( this.driver, signOutSelector ).then(
() => {},
() => {
// Occasionally the click doesn't work on mobile due to the drawer animation, so retry once
driverHelper.clickWhenClickable( this.driver, signOutSelector );
return driverHelper.waitTillNotPresent( this.driver, signOutSelector );
}
);
}
async chooseManagePurchases() {
await this._closeProfileViewOnMobile();
return await driverHelper.clickWhenClickable(
this.driver,
by.css( '.sidebar a[href$="purchases"]' )
);
}
async chooseAccountSettings() {
await this._closeProfileViewOnMobile();
return await driverHelper.clickWhenClickable(
this.driver,
by.css( '.sidebar a[href$="account"]' )
);
}
async _closeProfileViewOnMobile() {
if ( driverManager.currentScreenSize() !== 'mobile' ) {
return;
}
let displayed = await driverHelper.isElementPresent( this.driver, by.css( '.focus-content' ) );
if ( displayed ) {
await this.driver.executeScript( 'window.scrollTo(0, 0);' );
return await driverHelper.clickWhenClickable(
this.driver,
by.css( 'header.current-section a' )
);
}
}
}