New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Puppeteer - I.getCurrentUrl() returns last URL rather than current url #963
Comments
The But could you please elaborate and fill out the issue template in full so we can address the problem more easily. |
Yes, I just added the function to the helper in the codecept node_module folder (saw the pull request for it) (as puppeteer custom helpers do not work right now). I added the code above. From https://github.com/GoogleChrome/puppeteer/blob/master/docs/api.md#puppeteerlaunchoptions - |
@awshanks There are few things that are not clear to me.
Scenario('open browser and navigate to github.com', (I) => {
I.amOnPage('https://github.com/awshanks');
I.click('codecept_training_material');
I.retry(3).seeInCurrentUrl('codecept_training_material');
}); |
Okay, thanks for the workaround. Glad to have it documented here for reference. |
For the Puppeteer custom helper, I have the following function (works for selenium, nightmare etc, only addition is the page)
|
No the Puppeteer api is a little different to WebDriverIO etc. The So an example custom Helper function would look like this. async getCurrentUrl() {
const helper = this.helpers['Puppeteer'];
return helper.page.url();
} |
Here is the full example of a custom helper for sake of completeness. 'use strict';
let Helper = codecept_helper;
class MyCustomHelper extends Helper {
async getCurrentUrl() {
const helper = this.helpers['Puppeteer'];
return helper.page.url();
}
}
module.exports = MyCustomHelper; |
Ah, I see, maybe an example in the puppeteer documentation would help others? Again thanks for clarifying. |
@awshanks Not a problem I have just submitted a PR with a comment about how to access it from a custom Helper (like the example in the WebDriverIO). It will take a little bit before it is available from the doc website. |
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 #945). Maybe a solution is for me not to use hashHistory.push('URL_HERE') and instead use . Sharing my observation for awareness. puppeteer/puppeteer#257 |
What are you trying to achieve?
What do you get instead?
Details
The text was updated successfully, but these errors were encountered: