Skip to content

Driver service timeout#6151

Closed
grigaman wants to merge 671 commits intoSeleniumHQ:masterfrom
grigaman:driver-service-timeout
Closed

Driver service timeout#6151
grigaman wants to merge 671 commits intoSeleniumHQ:masterfrom
grigaman:driver-service-timeout

Conversation

@grigaman
Copy link
Copy Markdown

@grigaman grigaman commented Jul 12, 2018


This change is Reviewable

@grigaman
Copy link
Copy Markdown
Author

grigaman commented Jul 12, 2018

I tried to add tests on *DriverService with mocking via mockito for testing passing timeout, but couldn't create correct partial mocks. This tests could be written with JMockit, because it supports mocking/verifying any calls (constructors, static methods). If this dependency could be added, I can write tests (which check that timeout is used in method waitUntilAvailable) for every DriverService.

@barancev
Copy link
Copy Markdown
Member

Please don't add another mocking lib. If you need to mock a constructor you must be doing something wrong :) Or we have already written bad code that should be refactored for better testability.

@grigaman
Copy link
Copy Markdown
Author

grigaman commented Jul 12, 2018

I didn't add any another mocking tool without approval. I am discussing if test is needed and which test I can add.
I can to add such tests for every driver(except SafariDriverService, because can't mock usingTechnologyPreview, which is called inside Builder constructor):

  @Test
  public void builderPassesTimeoutToDriverService() {
    File exe = new File("someFile");
    Duration defaultTimeout = Duration.ofSeconds(20);
    Duration customTimeout = Duration.ofSeconds(60);

    GeckoDriverService.Builder builderMock = spy(GeckoDriverService.Builder.class);
    doReturn(exe).when(builderMock).findDefaultExecutable();
    builderMock.build();

    verify(builderMock).createDriverService(any(), anyInt(), eq(defaultTimeout), any(), any());

    builderMock.withTimeout(customTimeout);
    builderMock.build();
    verify(builderMock).createDriverService(any(), anyInt(), eq(customTimeout), any(), any());
  }

But in this test there is no big sense, because it checks that the timeout is passed to Builder.createDriverService and can't check that set timeout in Builder is used by DriverService.
With JMockit test can check that timeout is used inside DriverService (with Mockito I think such test couldn't be written). Example of working test:

  @Test
  public void builderPassesTimeoutToDriverService2(@Mocked CommandLine cmdLine) throws Exception {
    File exe = new File("someFile");
    Duration defaultTimeout = Duration.ofSeconds(20);
    Duration customTimeout = Duration.ofSeconds(60);

    GeckoDriverService.Builder builder = new GeckoDriverService.Builder();
    new Expectations(builder, PortProber.class) {{
      builder.findDefaultExecutable(); result = exe;

      PortProber.waitForPortUp(anyInt, (int) defaultTimeout.toMillis(), MILLISECONDS);
      PortProber.waitForPortUp(anyInt, (int) customTimeout.toMillis(), MILLISECONDS);
    }};
    GeckoDriverService ds = builder.build();
    ds.start();

    new VerificationsInOrder() {{
      PortProber.waitForPortUp(anyInt, (int) defaultTimeout.toMillis(), MILLISECONDS);
    }};

    builder.withTimeout(customTimeout);
    ds = builder.build();
    ds.start();

    new VerificationsInOrder() {{
      PortProber.waitForPortUp(anyInt, (int) customTimeout.toMillis(), MILLISECONDS);
    }};
  }

@shs96c
Copy link
Copy Markdown
Member

shs96c commented Jul 13, 2018

We have org.openqa.selenium.support.ui.Clock and org.openqa.selenium.support.ui.FakeClock if you need to control time in tests.

@shs96c
Copy link
Copy Markdown
Member

shs96c commented Jul 13, 2018

A better choice would be java.time.Clock as that's part of the JRE and probably something we should look at using anyway.

@shs96c
Copy link
Copy Markdown
Member

shs96c commented Jul 16, 2018

I've now migrated the code in Selenium to use java.time.Clock, btw, so this may need a rebase.

@grigaman
Copy link
Copy Markdown
Author

I made a rebase on my branch, there is no need to change anything, because *DriverService don't use Clock

@shs96c shs96c added the C-java Java Bindings label Jul 28, 2018
@grigaman
Copy link
Copy Markdown
Author

grigaman commented Sep 4, 2018

It has been passed one and a half months. Do we process this pull request and integrate setting timeout of starting browser?

lmtierney and others added 20 commits September 20, 2018 15:19
* Added a basic ServiceBuilder for Internet Explorer

Adds it to IE's `Driver` and allows it to be specified with a new `setIeService` in the general `Builder`.

Fixes SeleniumHQ#5983

* Added IE service
…ng configs out of JSON files or resources, and initialize new config instances with data loaded from default config resources.
This makes `getHeaders(String)` properly case-insensitive.
Eventually, the goal is to untangle ourselves from Jetty
entirely. The first step is to start replacing the test
usages with something that doesn't depend on a third
party library. Fortunately, since java 6 both OpenJDK
and the Oracle JDK have shipped with an HTTP server as
part of their own APIs. This has been exposed via a
JPMS module, and so it should be safe to rely on since I
don't think any of the developers use the IBM JDK for
development work.
We have a lot of boiler-plate code. Let's try and bring that
down to something sensible, and at the same time standardise
how we start new servers.
Configuration is split into two separate layers. The first
are implementations of `Config`. These provide raw access
to the config options, and can be implemented any way that
people choose.

The second layer are app-specific views of the `Config`s
available. These allow all configuration options to be put
into one place, and easily accessed and reasoned about.
…y security warning

This code is copied from the SeleniumServer in the current
Grid Node. Apparently it's important.
2) Fixing 'host' to be always '0.0.0.0' if not specified explicitly
p0deje and others added 26 commits September 20, 2018 15:26
Those were broken since 1229d40 which changed the upload path
Signed-off-by: Alex Rodionov <p0deje@gmail.com>
According to documentation at https://developer.mozilla.org/en-US/docs/Web/API/Window/pageYOffset window.pageYOffset may not return integer value. With the following changes in below we are checking the type of returned object and assigning respectively the value of 'yOffset'

Signed-off-by: Alexei Barantsev <barancev@gmail.com>
Signed-off-by: Alexei Barantsev <barancev@gmail.com>
The W3C WebDriver Specification dictates that checking for elements
being obscured by other elements should rely on calling
elementsFromPoint. However, there is a bug in IE's elementsFromPoint
implementation. if two sibling elements have the same z-index, the one
specified second in the DOM order is usually on top. The exception
is if there is a child element that has a specified z-index greater
than the ancestor z-index. The IE elementsFromPoint implementation
ignores the child element case, so we have to manually look for child
elements that may be rendered on top of the element found outside the
element DOM tree of the element we are attempting to interact with.
Continuation of fd52573. This change mimics Java bindings behavior.
Removing timeout from FirefoxBinary because it is not used

(cherry picked from commit 0e3a915)
…river-service-timeout2

# Conflicts:
#	java/client/src/org/openqa/selenium/chrome/ChromeDriverService.java
… for:

  ChromeDriverService.Builder
  EdgeDriverService.Builder
  GeckoDriverService.Builder
  XpiDriverService.Builder
  InternetExplorerDriverService.Builder
  OperaDriverService.Builder
@grigaman
Copy link
Copy Markdown
Author

I've committed tests which verify that timeout is passing to createDriverService for:
  ChromeDriverService.Builder
  EdgeDriverService.Builder
  GeckoDriverService.Builder
  XpiDriverService.Builder
  InternetExplorerDriverService.Builder
  OperaDriverService.Builder
SafariDriverService.Builder

@grigaman
Copy link
Copy Markdown
Author

Do we process this pull request and integrate setting timeout of starting browser?

@grigaman grigaman closed this Aug 8, 2019
@grigaman grigaman deleted the driver-service-timeout branch August 8, 2019 09:30
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

C-java Java Bindings

Projects

None yet

Development

Successfully merging this pull request may close these issues.