Skip to content
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

can i get an equivalant to browser.refresh(); #236

Closed
kdp88 opened this issue Jun 14, 2018 · 16 comments
Closed

can i get an equivalant to browser.refresh(); #236

kdp88 opened this issue Jun 14, 2018 · 16 comments
Labels
enhancement @serenity-js/protractor

Comments

@kdp88
Copy link

@kdp88 kdp88 commented Jun 14, 2018

as the title states is there a way to get browser.refresh(); to work or is there a serenity framework way to do it

@jan-molak jan-molak added the enhancement label Jun 14, 2018
@jan-molak
Copy link
Member

@jan-molak jan-molak commented Jun 14, 2018

Hey @kdp88!

Serenity/JS doesn't support that out of the box yet, but it definitely should :-)
The feature would require exposing one of either of those two methods on the BrowseTheWeb ability and creating an Interaction utilising that.

In the meantime, you could use something along those lines:

import { protractor } from 'protractor';
import { Interaction } from '@serenity-js/core/lib/screenplay';

const Refresh = () => Interaction.where(`#actor reloads the website`, actor => {
  return protractor.browser.refresh();
});

Does that help?
Jan

@kdp88
Copy link
Author

@kdp88 kdp88 commented Jun 14, 2018

@jan-molak can you give me your brain 😁🙃🙃 thanks dude appreciate ya

Edit @jan-molak would you create a directory that houses interactions

For example interactions/refresh.ts or another ts file that houses all costs that could be interactions

@jan-molak
Copy link
Member

@jan-molak jan-molak commented Jun 17, 2018

My brain is for hire, so you can most certainly have it! 😄

To answer your question - sure, interactions/refresh.ts sounds like a sensible place to host it, yes :-)

@kdp88
Copy link
Author

@kdp88 kdp88 commented Jun 19, 2018

@jan-molak any idea why protractor.browser.refresh(); does not work inside --headless mode (protractor.conf.js) but works flawlessly when --headless is commented out?

@kdp88
Copy link
Author

@kdp88 kdp88 commented Jun 20, 2018

@jan-molak also when i attempt to utilize the import statement
import { Interaction } from '@serenity-js/core';

i get the following error (screenshot) any ideas
image

@jan-molak
Copy link
Member

@jan-molak jan-molak commented Jun 20, 2018

Can you try with import { Interaction } from '@serenity-js/core/lib/screenplay';?

@jan-molak any idea why protractor.browser.refresh(); does not work inside --headless mode (protractor.conf.js) but works flawlessly when --headless is commented out?

Excellent question, I'm not sure. There's a number of quirks with the --headless mode, so I wouldn't be surprised if that was one of them... It is still a relatively young feature.

@kdp88
Copy link
Author

@kdp88 kdp88 commented Jun 21, 2018

Yes sir that worked like a charm also had to put export const, but for some reason it will not do the refresh in headless mode works perfectly without headless

@marktigno
Copy link

@marktigno marktigno commented Jun 21, 2018

Try to include the --no-sandbox with the --headless mode. It might work on that way. :)

@kdp88
Copy link
Author

@kdp88 kdp88 commented Jun 21, 2018

@marktigno thanks for the suggestion I got that one in my conf.js as well still no dice

@marktigno
Copy link

@marktigno marktigno commented Jun 22, 2018

another method would be opening again the same page and it will act as a refresh on the browser:

protected open(url: string, user = 'User') {
    return this.stage.theActorCalled(user).attemptsTo(
        Start.openPage(url),
    );
}

@kdp88
Copy link
Author

@kdp88 kdp88 commented Jun 23, 2018

@marktigno is there a way to store the url to use it as a variable, basically browser.getCurrentUrl(). Because I wont know the url to navigate to as it changes

I guess that would be another interaction? I cant recall if serenity has a native getCurrentUrl

@jan-molak
Copy link
Member

@jan-molak jan-molak commented Jun 26, 2018

There's a question that retrieves the value of the current URL so that you can assert on it. You could use the exact same mechanism in the interaction.

Does that help?
Jan

@marktigno
Copy link

@marktigno marktigno commented Jun 27, 2018

I didn't know about this until I found that now. Thank's @jan-molak! I need to do code change on my other tests here. 😄

@marktigno
Copy link

@marktigno marktigno commented Jul 9, 2018

Just another question, do you know any implementations to execute back navigation on the browser?

@jan-molak
Copy link
Member

@jan-molak jan-molak commented Jul 13, 2018

I'll make a mental note to add those interactions when I extract the @serenity-js/protractor module :-)

In the meantime:

import { protractor } from 'protractor';
import { Interaction } from '@serenity-js/core/lib/screenplay';

const Navigate = ({
  back: () => Interaction.where(`#actor navigates back`, actor => {
    return protractor.browser.navigate().back();
  }),
});

@marktigno
Copy link

@marktigno marktigno commented Jul 16, 2018

Nice! Thanks for that @jan-molak, I'm doing the same thing here on our end by adding those helper codes on our tests. In the future I'll send PR to have them included on the @serenity-js/protractor module. ^_^V

@jan-molak jan-molak added the @serenity-js/protractor label Jul 26, 2018
@jan-molak jan-molak added this to the 2.0 milestone Feb 6, 2019
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement @serenity-js/protractor
Projects
None yet
Development

No branches or pull requests

3 participants