Click link and wait for URL to change?
See original GitHub issueI’m trying to do something seemingly simple, yet I can’t get it to work properly. Others have asked similar questions, but the solutions haven’t fixed things for me.
I want to do the following:
- Click a form submit button
- Wait for the new page to load
- Expect the URL to be something else
Here is the relevant code:
beforeEach(function () {
ptor = protractor.getInstance();
ptor.ignoreSynchronization = true;
ptor.get('/campaigns');
}, 60000);
it("selecting continue", function() {
var continueBtn = element(by.id('continue'));
continueBtn.click().then(function() {
expect(ptor.getCurrentUrl()).toContain(ptor.baseUrl + '/templates');
});
});
Clicking the submit button can take some time (anywhere from 1 - 10+ secs on my local machine), before the new page is loaded.
The expect
statement consistently leads to an error:
Message:
Expected 'http://localhost:9000/campaigns' to contain 'http://localhost:9000/templates'.
Any thoughts on the correct way to resolve this?
Issue Analytics
- State:
- Created 9 years ago
- Comments:10 (2 by maintainers)
Top Results From Across the Web
wait for the url to change on click event - Stack Overflow
I have an image, on clicking the image the URL changes but the page is not reloaded(partial navigation). I have used window.location.href ...
Read more >How to get Selenium to wait for a page to load - BrowserStack
Wondering how to wait for a web page to load in Selenium testing? Read tutorial to understand 3 methods to execute the same....
Read more >wait - Cypress Documentation
Pass in an options object to change the default behavior of cy.wait() . Option, Default, Description. log, true, Displays the command in the...
Read more >Set up Safe Links policies in Microsoft Defender for Office 365
Admins can learn how to view, create, modify, and delete Safe Links ... Wait for URL scanning to complete before delivering the message ......
Read more >Waiting in Cypress and how to avoid it - Filip Hric
wait () in your test. Use "defaultCommandTimeout" to change default timeout. Every element you query for an element using .get() .contains() ...
Read more >Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start FreeTop Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
Top GitHub Comments
Wait doesn’t understand expectations, you need to return a ‘true’ or ‘false’ value:
@AEIOU-1 I had a similar issue, and here is my solution.