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
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
3 changed files
with
88 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,36 @@ | ||
import webdriver from 'selenium-webdriver'; | ||
import fs from 'fs-extra'; | ||
import config from 'config'; | ||
|
||
import * as mediaHelper from '../media-helper.js'; | ||
import * as driverManager from '../driver-manager.js'; | ||
import * as dataHelper from '../data-helper.js'; | ||
|
||
import GoogleSearchPage from '../pages/google-search.js'; | ||
|
||
export default class GoogleFlow { | ||
constructor( driver, screenSize ) { | ||
this.driver = driver; | ||
|
||
if ( screenSize === undefined ) { | ||
this.screenSize = driverManager.currentScreenSize(); | ||
} else { | ||
driverManager.resizeBrowser( driver, screenSize ); | ||
this.screenSize = screenSize; | ||
} | ||
} | ||
|
||
search( query, culture ) { | ||
var d = webdriver.promise.defer(); | ||
var driver = this.driver; | ||
var screenSize = this.screenSize; | ||
this.GoogleSearchPage = new GoogleSearchPage( driver, true, culture ); | ||
driver.sleep( 1000 ); | ||
driver.takeScreenshot().then( function( data ) { | ||
mediaHelper.writeScreenshot( data, culture.toUpperCase() + '_' + screenSize + 'GOOGLE', true ); | ||
} ); | ||
|
||
d.fulfill( true ); | ||
return d.promise; | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,20 @@ | ||
var webdriver = require( 'selenium-webdriver' ); | ||
var by = webdriver.By; | ||
var until = webdriver.until; | ||
var config = require( 'config' ); | ||
|
||
function GoogleSearchPage( driver, visit, culture ) { | ||
this.driver = driver; | ||
this.explicitWaitMS = config.get( 'explicitWaitMS' ); | ||
this.expectedElementSelector = by.id( "com.google.ads.apps.anonymousapt.GwtModule" ); | ||
if ( visit === true ) { | ||
if ( culture === undefined ) { | ||
culture = "en"; | ||
} | ||
var url = "https://adwords.google.com/apt/anon/AdPreview"; | ||
driver.get( url ); | ||
} | ||
this.driver.wait( until.elementLocated( this.expectedElementSelector ), this.explicitWaitMS, 'Could not locate the Google Ad Preview IFrame. Check that is is displayed.' ); | ||
}; | ||
|
||
module.exports = GoogleSearchPage; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,32 @@ | ||
import test from 'selenium-webdriver/testing'; | ||
import config from 'config'; | ||
|
||
import * as driverManager from '../lib/driver-manager.js'; | ||
|
||
import GoogleFlow from '../lib/flows/google-flow.js'; | ||
|
||
const mochaTimeOut = config.get( 'mochaTimeoutMS' ); | ||
const startBrowserTimeoutMS = config.get( 'startBrowserTimeoutMS' ); | ||
|
||
const culture = process.env.CULTURE || 'en'; | ||
|
||
var driver; | ||
|
||
test.before( function() { | ||
this.timeout( startBrowserTimeoutMS ); | ||
driver = driverManager.startBrowser(); | ||
} ); | ||
|
||
test.describe( 'Search for WordPress on Google', function() { | ||
this.timeout( mochaTimeOut ); | ||
|
||
test.beforeEach( function() { | ||
driver.manage().deleteAllCookies(); | ||
driverManager.deleteLocalStorage( driver ); | ||
} ); | ||
|
||
test.it( `Can load Google`, function() { | ||
const googleFlow = new GoogleFlow( driver, 'desktop' ); | ||
googleFlow.search( 'wordpress', culture ); | ||
} ); | ||
} ); |