Puppeteer - I.getCurrentUrl() returns last URL rather than current url
See original GitHub issueWhat are you trying to achieve?
What do you get instead?
Provide console output if related. Use
--verbose
mode for more details.
Open Github @sample --
open browser and navigate to github.com
• I am on page "https://github.com/awshanks"
• I click "codecept_training_material"
• I get current url
https://github.com/awshanks
Provide test source code if related
Scenario('open browser and navigate to github.com', (I) => {
I.amOnPage('https://github.com/awshanks');
I.click('codecept_training_material');
I.getCurrentUrl().then(function (result) {
console.log(result);
});
});
Details
- CodeceptJS version: 1.1.5 (puppeteer 1.1.0)
- NodeJS Version: 8.9.4
- Operating System: MacOS
- Protractor || WebDriverIO || Nightmare version (if related)
- Configuration file:
# paste suite config here
Issue Analytics
- State:
- Created 6 years ago
- Comments:10 (5 by maintainers)
Top Results From Across the Web
Puppeteer - I.getCurrentUrl() returns last URL rather than ...
No the Puppeteer api is a little different to WebDriverIO etc. The .url() function is actually on the Page object and not the...
Read more >How To Get The URL After Redirecting from Current Page ...
type('input#password' , "puppeteer"); await page.click('#signBtn').then(await console.log(page.
Read more >Puppeteer
Retrieves an attribute from an element located by CSS or XPath and returns it to test. Resumes test execution, so should be used...
Read more >Get Current URL in Selenium using Python: Tutorial
Using the Current URL method in Selenium to perform a URL check on google.com. Step 1: Import the required packages using the following...
Read more >Getting the URL of the current page using Selenium ...
We can obtain the URL of the current page with Selenium webdriver. This is achieved with the help of getCurrentUrl() method.
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
Here is the full example of a custom helper for sake of completeness.
Okay, I think I’ve narrowed down the issue I was having and it seems that if a website use hash routing the page.url doesn’t update after a click that directs to another page.
The I.click works fine and goes to the page and I see the url in the verbose output.
If I go to the page with I.amOnPage(‘/#/page’) the route will change (and with show:true on I can see the correct page), but codecept doesn’t know that the page has changed and the amOnPage will fails after it retries and I always just have the baseUrl that I defined in the config. (related to https://github.com/Codeception/CodeceptJS/issues/945). Maybe a solution is for me not to use hashHistory.push(‘URL_HERE’) and instead use <Link>. Sharing my observation for awareness. https://github.com/GoogleChrome/puppeteer/issues/257