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

Add a helper method to open a url in a new tab #182

Merged
merged 2 commits into from Jan 6, 2016
Merged

Add a helper method to open a url in a new tab #182

merged 2 commits into from Jan 6, 2016

Conversation

YannMoisan
Copy link
Contributor

No description provided.

@buildhive
Copy link

FluentLenium » FluentLenium #201 UNSTABLE
Looks like there's a problem with this pull request
(what's this?)

@filipcynarski
Copy link
Member

Thank you for working on this. Feature seems to be good addition to FluentLenium functionalities.

Have you run tests before you pushed the code to the VCS? Seems like one test is failing: org.fluentlenium.integration.FluentLeniumWaitTest.checkPolling please check what might be broken by your change if you want to have your change merged w/ current code.

if (baseUrl != null) {
URI uri = URI.create(url);
if (!uri.isAbsolute()) {
url = baseUrl + url;
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'm not sure if you want to always use base URL as a part of URL construction.
Java has gently mechanism to compose URL instead of String adding.

URL myURL = new URL("http://example.com/pages/");
URL page1URL = new URL(myURL, "page1.html");
URL page2URL = new URL(myURL, "page2.html");

Could you re-factor this method to do it in the better way?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The URL construction logic comes from the existing method goTo.

@buildhive
Copy link

FluentLenium » FluentLenium #211 SUCCESS
This pull request looks good
(what's this?)

@filipcynarski
Copy link
Member

I'm not sure but probably we are not supporting tabs switch, so if we are going to support new tab creation we should also support tabs switching are you able to extend your code to support such feature?

@YannMoisan
Copy link
Contributor Author

Do you want this support in the same PR ?

Do you thing to a switchToTab(int: tabNumber) ?

The tricky thing is that getWindowHandles() returns a Set, so unordered.
This mean that we should keep a state (ordered list of handles) in the Fluent class…

A switchToOtherTab() will only work with 2 tabs but is easier to implement, because there is no need to maintain a state.

Let me know…

@filipcynarski
Copy link
Member

I think it might be a few versions:

  • switchToTab(int: tabNumber)
  • switchToTab(URL: urlPart)
  • switchToNextTab() - should switch to 1st tab when you are on the last tab

@YannMoisan
Copy link
Contributor Author

switchToTab(URL: urlPart)

There could be more than one tab opened with the same URL

Another point, ordered-aware switch will work only if all tabs are open with the method goToInNewTab (due to the need to maintain a state).

@Toilal
Copy link
Member

Toilal commented Nov 6, 2015

What is the concrete implementation of Set ? Some Set may have a defined iteration order (LinkedHashSet).

Set<String> initialTabs = getDriver().getWindowHandles();
executeScript("window.open('" + url + "', '_blank');");
Set<String> tabs = getDriver().getWindowHandles();
tabs.removeAll(initialTabs);
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The 3 previous lines requires thread synchronization

@Toilal Toilal merged commit 8bbcd00 into FluentLenium:master Jan 6, 2016
Toilal added a commit that referenced this pull request Jan 6, 2016
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

4 participants