Comments (8)
I'd considered this and wasn't sure what would be most intuitive to people - truly wrapping the driver, or keeping both around. I take this as a vote for the former, and I think I prefer that as well. I'd love to hear others' votes, too.
from protractor.
I agree, I think keeping both around would be good. That way some e2e tests could simply use the driver for non-angular pages.
Currently when I try to use them side by side like so:
ptor.get("http://www.smashingmagazine.com");
driver.getTitle().then(function(title) {...
It errors out:
UnknownError: Error Message => 'Detected a page unload event; asynchronous script execution does not work across page loads.'
After we fix that, maybe we just add a driver
property to the ptor instance so it doesn't have to be passed around manually:
ptor.get("http://www.smashingmagazine.com");
ptor.driver.getTitle().then(function(title) {...
Thoughts?
EDIT: looks like there already is a driver
property on the instance. So just fixing the other issue may be sufficient.
from protractor.
Heya,
Added full wrapping on the 'wrapfix' branch with 40d8a7a. Does this look sane (and fix your issue?)
from protractor.
Hi Julie,
I don't know webdriver in detail, but maybe you also need to preserve the this pointer in the webdriver functions to point to the webdriver instance, e.g.
// Mix all other driver functionality into Protractor.
for (var foo in webdriver) {
if(!this[foo]) {
this[foo] = webdriver[foo].bind(webdriver);
}
}
Furthermore, for chaining functions, your mixed in functions should return the protractor instance, and not the webdriver instance, e.g.
// Mix all other driver functionality into Protractor.
for (var foo in webdriver) {
if(!this[foo]) {
mixin(this, webdriver, foo);
}
}
function mixin(self, webdriver, fnName) {
self[fnName] = function() {
var res = webdriver[fnName].apply(this, arguments);
if (res===webdriver) {
res = self;
}
return res;
}
}
Does this make sense?
Tobias
from protractor.
Tobias - thanks for the comments, can't believe I forgot to fix the binding.
However, on second thought, it might be best to really just delegate to webdriver, since there aren't any non-function members of the webdriver object that I want to copy to the protractor object. For example:
for (var foo in webdriver) {
if(!this[foo] && typeof webdriver[foo] == "function") {
this[foo] = function() {
return webdriver[foo](webdriver, arguments);
};
}
}
Any comments on this style?
from protractor.
Alternative B: Decorate the webdriver instance, instead of creating a separate protractor object.
Protractor.wrapDriver = function(webdriver) {
webdriver.extend(Protractor.prototype);
};
from protractor.
Implemented Tobias's suggestion (minus chaining, since there is no chaining in webdriverjs) with 1ef76dc
from protractor.
Merged into master. Thanks for the comments, everyone!
from protractor.
Related Issues (20)
- Support on Protractor after 2022 and any plans for licensed version HOT 7
- Error: Timeout - Async callback was not invoked within timeout specified by jasmine.DEFAULT_TIMEOUT_INTERVAL. HOT 4
- Callback function is taking long after completing the run in the protractor testcase
- [BUG] Upgrade transitive dependency "[email protected]" to fix CVE-2021-3918 HOT 1
- [BUG] input with dropdown use clear the selected tag won't remove, and click will click on the text not the element.
- Is protractor no longer working when using Angular 13? HOT 8
- protractor.Key.chord() broken in the latest chromedriver HOT 3
- Prototype Pollution in minimist
- qs version CVE-2021-44907 (High) detected in my repo dependencies
- need support for finding element under shadow root HOT 3
- Feature request - html to pdf
- Git.io deprecation notice
- Getting the ERROR "This driver instance does not have a valid session ID (did you call WebDriver.quit()?) and may no longer be used." When I try to use restart() or close() method HOT 2
- Deprecated warning with Protractor HOT 2
- Interview partners for research about communication in GitHub projects wanted
- Can existing Protractor automation scripts developed in year 2020 supported on windows 2019 OS server
- webdriver Manager , chrome version higher then 114 HOT 3
- Migrate Protractor to Playwright
- Meera HOT 1
- Performance Dashboard
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from protractor.