Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Micro: bit selenium test code refactor #5745

Merged
merged 31 commits into from
Jul 31, 2019
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
Show all changes
31 commits
Select commit Hold shift click to select a range
1096f7f
ui test initial import
Helen09 May 23, 2019
74a4d96
add README.md file
Helen09 May 27, 2019
2cafc85
Change of dependencies and refactor
jieliu2000 May 30, 2019
eba6ebf
Changes of framwork
jieliu2000 Jun 1, 2019
2bf94c3
Remove useless code
jieliu2000 Jun 9, 2019
2c4487e
Refactor of new project testing (uncompleted)
jieliu2000 Jun 9, 2019
a6f2325
Update of newProject.js
jieliu2000 Jun 9, 2019
07c6e86
Refactor of the code structure
jieliu2000 Jun 13, 2019
e430bb4
Fix errors of tests
jieliu2000 Jun 13, 2019
8e8700d
Refactor and clean code
jieliu2000 Jun 13, 2019
fd330ae
Fix errors
jieliu2000 Jun 13, 2019
cf66721
Renaming files
jieliu2000 Jun 13, 2019
078e55a
refactor and remove useless code
jieliu2000 Jun 13, 2019
6045924
Merge pull request #2 from jieliu2000/refactor
jieliu2000 Jun 13, 2019
f242be7
Send keys to inpur
jieliu2000 Jun 13, 2019
2ec1d96
Merge pull request #3 from jieliu2000/refactor
jieliu2000 Jun 13, 2019
5082457
Remove useless code
jieliu2000 Jun 13, 2019
75e8493
Merge pull request #5 from jieliu2000/refactor
jieliu2000 Jun 13, 2019
aedf8cb
Modified the file's format and update new-project.js
StevenH8 Jul 5, 2019
6319549
pxt ui test initial import
Helen09 Jul 11, 2019
ab9c5e8
delete extra files
Helen09 Jul 11, 2019
93ec2c9
update new-project
Helen09 Jul 11, 2019
66d0f29
Refactor and clean code
jieliu2000 Jul 11, 2019
15205d4
Change test description
jieliu2000 Jul 11, 2019
f494ba0
Update screenshots capture related code
jieliu2000 Jul 11, 2019
172d7c6
Refactor and clean code
jieliu2000 Jul 11, 2019
3398ecf
update description in package.json
Helen09 Jul 11, 2019
e16eaec
Update console debug information
jieliu2000 Jul 11, 2019
d304e1c
Merge branch 'selenium-test' of https://github.com/Helen09/pxt into s…
jieliu2000 Jul 11, 2019
08e2769
delete useless code in dom-object.js
Helen09 Jul 18, 2019
48e2655
Merge branch 'selenium-test' of https://github.com/Helen09/pxt into s…
Helen09 Jul 18, 2019
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
Next Next commit
Refactor and clean code
  • Loading branch information
jieliu2000 committed Jun 13, 2019
commit 8e8700d439b729db85a12c007efa4ba7ae802b80
34 changes: 0 additions & 34 deletions tests/ui-test/src/Main1.js

This file was deleted.

41 changes: 2 additions & 39 deletions tests/ui-test/src/NewProject.js
Original file line number Diff line number Diff line change
@@ -1,42 1,6 @@
const { By } = require('selenium-webdriver');
import {DomObject} from './lib/domObject';
import {By} from 'selenium-webdriver';

class DomObject {

async actionForAll(actionName, findBys) {
for (let findBy of findBys) {
if (findBy) {
console.debug(`Try to click the element by criteria: ${findBy}`);

if (typeof findBy === 'string') {
findBy = await By.css(findBy);
}

let element = await driver.wait(until.elementLocated(findBy));
await driver.sleep(1000);
await element[actionName]();
}
}
return true;
}

async sendKeys(findBy, keys) {

if (typeof findBy === 'string') {
findBy = await By.css(findBy);
}

let element = await driver.findElement(findBy);
await element["actionName"](keys);
await driver.sleep(8000);
return true;
}


async click(...findBys) {
let i = await this.actionForAll('click', findBys);
return i;
}
}
class NewProjectPage extends DomObject {

async getCodeSource() {
Expand All @@ -61,7 25,6 @@ class NewProjectPage extends DomObject {
return await this.testGetCodeSource();
});
}

}

export let newProjectPage = new NewProjectPage();
43 changes: 43 additions & 0 deletions tests/ui-test/src/lib/domObject.js
Original file line number Diff line number Diff line change
@@ -0,0 1,43 @@
import {By} from 'selenium-webdriver';

export class DomObject {

async actionForAll(actionName, findBys) {
for (let criteria of findBys) {
if (criteria) {
console.debug(`Try to click the element by criteria: ${criteria}`);

let findBy = this.findBy(criteria);

//wait until the element can be located
await driver.wait(until.elementLocated(findBy));

let element = await driver.wait(until.elementLocated(findBy));
await driver.sleep(1000);
await element[actionName]();
}
}
return true;
}

findBy(criteria){
if (typeof criteria === 'string') {
return await By.css(criteria);
}
return criteria
}

async sendKeys(criteria, keys) {

let element = await driver.findElement(this.findBy(criteria));
await element["actionName"](keys);

return true;
}


async click(...findBys) {
let i = await this.actionForAll('click', findBys);
return i;
}
}
8 changes: 4 additions & 4 deletions tests/ui-test/src/lib/website.js
Original file line number Diff line number Diff line change
@@ -1,4 1,4 @@
import webdriver from 'selenium-webdriver';
import {Builder, until} from 'selenium-webdriver';
import {chrome} from 'selenium-webdriver/chrome';


Expand All @@ -13,7 13,7 @@ class Website {
async open(path = "") {
var fullPath = this.getUrl(path);
console.log(`Open url ${fullPath}`);

await driver.get(fullPath);

console.info(`Opened URL ${fullPath}`);
Expand All @@ -35,10 35,10 @@ class Website {
}


global.driver = new webdriver.Builder()
global.driver = new Builder()
.forBrowser('chrome')
.build();
global.until = webdriver.until;
global.until = until;


export let website = new Website();