Skip to content
This repository was archived by the owner on Jul 29, 2024. It is now read-only.

Commit 4345fa3

Browse files
committed
address comments
- add comments - remove gulpfile types task - remove webdriver namespace from globals.d.ts
1 parent c59cbe5 commit 4345fa3

File tree

5 files changed

+22
-36
lines changed

5 files changed

+22
-36
lines changed

gulpfile.js

Lines changed: 5 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -49,9 +49,10 @@ gulp.task('checkVersion', function(done) {
4949
}
5050
});
5151

52-
gulp.task('built:copy', function() {
53-
return gulp.src(['lib/**/*.js','lib/globals.d.ts'])
52+
gulp.task('built:copy', function(done) {
53+
return gulp.src(['lib/**/*.js','lib/globals.d.ts','lib/index.d.ts'])
5454
.pipe(gulp.dest('built/'));
55+
done();
5556
});
5657

5758
gulp.task('webdriver:update', function(done) {
@@ -88,29 +89,14 @@ gulp.task('tsc:globals', function(done) {
8889
});
8990

9091
gulp.task('prepublish', function(done) {
91-
runSequence('checkVersion', ['jshint', 'format'], 'tsc', 'tsc:globals', 'types',
92+
runSequence('checkVersion', ['jshint', 'format'], 'tsc', 'tsc:globals',
9293
'built:copy', done);
9394
});
9495

9596
gulp.task('pretest', function(done) {
9697
runSequence('checkVersion',
9798
['webdriver:update', 'jshint', 'format'], 'tsc', 'tsc:globals',
98-
'types', 'built:copy', done);
99+
'built:copy', done);
99100
});
100101

101102
gulp.task('default',['prepublish']);
102-
103-
gulp.task('types', function(done) {
104-
var outputFile = path.resolve('built', 'index.d.ts');
105-
var contents = '';
106-
contents += '/// <reference path="../typings/index.d.ts" />\n';
107-
contents += '/// <reference path="./globals.d.ts" />\n';
108-
contents += 'export { ElementHelper, ProtractorBrowser } from \'./browser\';\n';
109-
contents += 'export { ElementArrayFinder, ElementFinder } from \'./element\';\n';
110-
contents += 'export { ProtractorExpectedConditions } from \'./expectedConditions\';\n';
111-
contents += 'export { ProtractorBy } from \'./locators\';\n';
112-
contents += 'export { Config } from \'./config\';\n';
113-
contents += 'export { Ptor } from \'./ptor\';\n';
114-
fs.writeFileSync(outputFile, contents);
115-
done();
116-
});

lib/browser.ts

Lines changed: 6 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -34,6 +34,7 @@ for (let foo in webdriver) {
3434
}
3535

3636
// Explicitly define webdriver.WebDriver
37+
// TODO: extend WebDriver from selenium-webdriver typings
3738
export class Webdriver {
3839
actions: () => ActionSequence;
3940
call:
@@ -508,7 +509,7 @@ export class ProtractorBrowser extends Webdriver {
508509
'Timed out waiting for Protractor to synchronize with ' +
509510
'the page after ' + timeout + '. Please see ' +
510511
'https://github.com/angular/protractor/blob/master/docs/faq.md';
511-
if (description.startsWith(' - Locator: ')) {
512+
if (description.indexOf(' - Locator: ') == 0) {
512513
errMsg +=
513514
'\nWhile waiting for element with locator' + description;
514515
}
@@ -773,17 +774,14 @@ export class ProtractorBrowser extends Webdriver {
773774
'return window.location.href;', msg('get url'))
774775
.then(
775776
(url: any) => { return url !== this.resetUrl; },
776-
(err: webdriver.ErrorCode) => {
777+
(err: IError) => {
777778
if (err.code == 13) {
778779
// Ignore the error, and continue trying. This is
779-
// because IE
780-
// driver sometimes (~1%) will throw an unknown error
781-
// from this
782-
// execution. See
780+
// because IE driver sometimes (~1%) will throw an
781+
// unknown error from this execution. See
783782
// https://github.com/angular/protractor/issues/841
784783
// This shouldn't mask errors because it will fail
785-
// with the timeout
786-
// anyway.
784+
// with the timeout anyway.
787785
return false;
788786
} else {
789787
throw err;

lib/element.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,7 @@ let WEB_ELEMENT_FUNCTIONS = [
1818
];
1919

2020
// Explicitly define webdriver.WebElement.
21+
// TODO: extend WebElement from selenium-webdriver typings
2122
export class WebdriverWebElement {
2223
getDriver: () => WebDriver;
2324
getId: () => wdpromise.Promise<any>;

lib/globals.d.ts

Lines changed: 2 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,7 @@ declare namespace NodeJS {
1313
}
1414

1515
interface Global {
16+
// These are here because we tie these variables to the global namespace.
1617
browser: any;
1718
protractor: any;
1819
$: any;
@@ -24,7 +25,7 @@ declare namespace NodeJS {
2425
DartObject: any;
2526
Command: any;
2627
CommandName: any;
27-
// Helper function added by the debugger in protractor.ps
28+
// Helper function added by the debugger and element explorer
2829
list: (locator: any) => string[];
2930
[key: string]: any;
3031
}
@@ -35,12 +36,4 @@ declare interface IError extends Error {
3536
stack?: string;
3637
}
3738

38-
declare interface String { startsWith: Function; }
39-
40-
declare namespace webdriver {
41-
class ErrorCode {
42-
code: number;
43-
}
44-
}
45-
4639
declare interface HttpProxyAgent { constructor(opts: Object): HttpProxyAgent; }

lib/index.d.ts

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
/// <reference path="../typings/index.d.ts" />
2+
/// <reference path="./globals.d.ts" />
3+
export {ElementHelper, ProtractorBrowser} from './browser';
4+
export {Config} from './config';
5+
export {ElementArrayFinder, ElementFinder} from './element';
6+
export {ProtractorExpectedConditions} from './expectedConditions';
7+
export {ProtractorBy} from './locators';
8+
export {Ptor} from './ptor';

0 commit comments

Comments
 (0)