Comments (4)
Here's a little example, I think this test sucks:
it('should send and receive a message', function () {
var input = ptor.findElement(protractor.By.input('newMessage'));
var button = ptor.findElement(protractor.By.css('[ng-click="publish()"]'));
var newMessageReceived = false;
ptor.wait(function () {
input.sendKeys('testing');
button.click();
ptor.findElements(
protractor.By.repeater('message in messages').column('{{message}}'))
.then(function (msgs) {
msgs[0].getText().then(function (text) { // new messages are unshifted
if (text === 'Waiting_Room -> testing') {
newMessageReceived = true;
}
});
});
if (newMessageReceived) {
expect(newMessageReceived).toBe(true);
return true;
}
}, 5000);
});
From what I can tell, the scenario is that on page load, there is a slight amount of time needed to make a connection to the pubsub server, but the test is already firing off messages (which don't get sent yet). I am waiting for responses come back from the server, but have noticed that they don't come through until about the 4th button.click()
. Do you know a better way to do a test like this?
from protractor.
I confirmed that the problem is because the connection to the pubsub server doesn't finish initializing until about a second after page load. This test might be slightly better, please let me know if this is more appropriate or if there's a better way for protractor to handle this scenario.
it('should send and receive a message', function () {
var input = ptor.findElement(protractor.By.input('newMessage'));
var button = ptor.findElement(protractor.By.css('[ng-click="publish()"]'));
waits(2000);
setTimeout(function () {
input.sendKeys('testing');
button.click();
setTimeout(function () {
ptor.findElements(
protractor.By.repeater('message in messages').column('{{message}}'))
.then(function (msgs) {
msgs[0].getText().then(function (text) { // new message is unshifted
expect(text).toBe('Waiting_Room -> testing');
});
});
}, 300);
}, 1000);
});
from protractor.
Is there a way to tell if the pubsub is up and running more easily than clicking something and seeing what happens? You can use ptor.wait with any function, so if you do have mycondition_to_continue_testing_fn()
, you can do:
ptor.wait(mycondition_to_continue_testing_fn());
var input = ptor.findElement(...)
Maybe there is a variable that gets initiated in the browser or somthing? Could you test for the pubsub with ptor.executeScript()
? See https://code.google.com/p/selenium/source/browse/javascript/webdriver/webdriver.js#375 for the docs on that.
Otherwise, using ptor.sleep(2000)
is preferable to using waits(2000)
.
from protractor.
Closing as there seem to be no further questions - please reopen if something else comes up.
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.