-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathsample.js
More file actions
68 lines (48 loc) · 1.83 KB
/
sample.js
File metadata and controls
68 lines (48 loc) · 1.83 KB
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
61
62
63
64
65
66
67
68
const Utils = require('./lib/TestUtil');
require('chromedriver');
require('geckodriver');
var assert = require('assert');
const {Builder, By, Key, until , Actions } = require('selenium-webdriver');
const config = {};
config.url = 'https://www.google.co.jp/';
config.outdir = 'ss';
testMain(process.argv[2]);
// testMain('firefox');
async function testMain (browser){
let driver = await new Builder().forBrowser(browser).build();
let u = new Utils(driver);
(function ( browser ){
test('test001');
}(browser));
// テストその1
async function test(name){
const scrDir = "./scr/"+browser+'/'+name;
try {
await driver.get(config.url);
await u.waitForLoadBy(By.name('q'));
u.takeScr(scrDir,name+'-001.jpg');
await driver.findElement(By.name("q")).sendKeys('selenium javascript',Key.ENTER);
await u.takeScr(scrDir,name+'-002.jpg');
await u.waitForLoadBy(By.id('pnnext'));
await u.scrollBy(By.id("pnnext"));
await u.takeScr(scrDir,name+'-003.jpg');
await u.clickBy(By.id("pnnext"));
await u.takeScr(scrDir,name+'-004.jpg');
await u.waitForLoadBy(By.id('pnnext'));
await u.takeScr(scrDir,name+'-005.jpg');
var elmlast = null;
var elements = driver.findElements(By.partialLinkText("Selenium"));
for(let elm of (await elements)) {
elmlast = elm;
}
if(elmlast!= null){
await elmlast.click();
await u.takeScr(scrDir,name+'-006.jpg');
}
}
finally {
await driver.quit();
console.log(name+ ' done');
}
}
}