Class RemoteWebDriver

java.lang.Object
org.openqa.selenium.remote.RemoteWebDriver
All Implemented Interfaces:
org.openqa.selenium.federatedcredentialmanagement.HasFederatedCredentialManagement, org.openqa.selenium.HasCapabilities, org.openqa.selenium.HasDownloads, org.openqa.selenium.interactions.Interactive, org.openqa.selenium.JavascriptExecutor, org.openqa.selenium.PrintsPage, org.openqa.selenium.SearchContext, org.openqa.selenium.TakesScreenshot, org.openqa.selenium.virtualauthenticator.HasVirtualAuthenticator, org.openqa.selenium.WebDriver

public class RemoteWebDriver extends Object implements org.openqa.selenium.WebDriver, org.openqa.selenium.JavascriptExecutor, org.openqa.selenium.HasCapabilities, org.openqa.selenium.HasDownloads, org.openqa.selenium.federatedcredentialmanagement.HasFederatedCredentialManagement, org.openqa.selenium.virtualauthenticator.HasVirtualAuthenticator, org.openqa.selenium.interactions.Interactive, org.openqa.selenium.PrintsPage, org.openqa.selenium.TakesScreenshot
  • Field Details

    • capabilities

      protected org.openqa.selenium.Capabilities capabilities
  • Constructor Details

    • RemoteWebDriver

      protected RemoteWebDriver()
    • RemoteWebDriver

      public RemoteWebDriver(org.openqa.selenium.Capabilities capabilities)
    • RemoteWebDriver

      public RemoteWebDriver(org.openqa.selenium.Capabilities capabilities, boolean enableTracing)
    • RemoteWebDriver

      public RemoteWebDriver(URL remoteAddress, org.openqa.selenium.Capabilities capabilities)
    • RemoteWebDriver

      public RemoteWebDriver(URL remoteAddress, org.openqa.selenium.Capabilities capabilities, org.openqa.selenium.remote.http.ClientConfig clientConfig)
    • RemoteWebDriver

      public RemoteWebDriver(URL remoteAddress, org.openqa.selenium.Capabilities capabilities, boolean enableTracing)
    • RemoteWebDriver

      public RemoteWebDriver(URL remoteAddress, org.openqa.selenium.Capabilities capabilities, org.openqa.selenium.remote.http.ClientConfig clientConfig, boolean enableTracing)
    • RemoteWebDriver

      public RemoteWebDriver(CommandExecutor executor, org.openqa.selenium.Capabilities capabilities)
    • RemoteWebDriver

      public RemoteWebDriver(CommandExecutor executor, org.openqa.selenium.Capabilities capabilities, org.openqa.selenium.remote.http.ClientConfig clientConfig)
  • Method Details

    • builder

      @Beta public static RemoteWebDriverBuilder builder()
    • getSessionId

      public SessionId getSessionId()
    • setSessionId

      protected void setSessionId(String opaqueKey)
    • startSession

      protected void startSession(org.openqa.selenium.Capabilities capabilities)
    • getErrorHandler

      public ErrorHandler getErrorHandler()
    • setErrorHandler

      public void setErrorHandler(ErrorHandler handler)
    • getClientConfig

      public org.openqa.selenium.remote.http.ClientConfig getClientConfig()
    • getCommandExecutor

      public CommandExecutor getCommandExecutor()
    • setCommandExecutor

      protected void setCommandExecutor(CommandExecutor executor)
    • getCapabilities

      public @NonNull org.openqa.selenium.Capabilities getCapabilities()
      Specified by:
      getCapabilities in interface org.openqa.selenium.HasCapabilities
    • get

      public void get(String url)
      Specified by:
      get in interface org.openqa.selenium.WebDriver
    • getTitle

      public String getTitle()
      Specified by:
      getTitle in interface org.openqa.selenium.WebDriver
    • getCurrentUrl

      public String getCurrentUrl()
      Specified by:
      getCurrentUrl in interface org.openqa.selenium.WebDriver
    • getScreenshotAs

      public <X> X getScreenshotAs(org.openqa.selenium.OutputType<X> outputType) throws org.openqa.selenium.WebDriverException
      Specified by:
      getScreenshotAs in interface org.openqa.selenium.TakesScreenshot
      Throws:
      org.openqa.selenium.WebDriverException
    • print

      public org.openqa.selenium.Pdf print(org.openqa.selenium.print.PrintOptions printOptions) throws org.openqa.selenium.WebDriverException
      Specified by:
      print in interface org.openqa.selenium.PrintsPage
      Throws:
      org.openqa.selenium.WebDriverException
    • findElement

      public org.openqa.selenium.WebElement findElement(org.openqa.selenium.By locator)
      Specified by:
      findElement in interface org.openqa.selenium.SearchContext
      Specified by:
      findElement in interface org.openqa.selenium.WebDriver
    • findElements

      public List<org.openqa.selenium.WebElement> findElements(org.openqa.selenium.By locator)
      Specified by:
      findElements in interface org.openqa.selenium.SearchContext
      Specified by:
      findElements in interface org.openqa.selenium.WebDriver
    • findElements

      public List<org.openqa.selenium.WebElement> findElements(org.openqa.selenium.SearchContext context, BiFunction<String,Object,CommandPayload> findCommand, org.openqa.selenium.By locator)
    • setFoundBy

      protected void setFoundBy(org.openqa.selenium.SearchContext context, org.openqa.selenium.WebElement element, String by, String using)
    • getPageSource

      public String getPageSource()
      Specified by:
      getPageSource in interface org.openqa.selenium.WebDriver
    • close

      public void close()
      Specified by:
      close in interface org.openqa.selenium.WebDriver
    • quit

      public void quit()
      Specified by:
      quit in interface org.openqa.selenium.WebDriver
    • getWindowHandles

      public Set<String> getWindowHandles()
      Specified by:
      getWindowHandles in interface org.openqa.selenium.WebDriver
    • getWindowHandle

      public String getWindowHandle()
      Specified by:
      getWindowHandle in interface org.openqa.selenium.WebDriver
    • executeScript

      public @Nullable Object executeScript(@NonNull String script, @Nullable Object... args)
      Specified by:
      executeScript in interface org.openqa.selenium.JavascriptExecutor
    • executeAsyncScript

      public Object executeAsyncScript(String script, Object... args)
      Specified by:
      executeAsyncScript in interface org.openqa.selenium.JavascriptExecutor
    • switchTo

      public org.openqa.selenium.WebDriver.TargetLocator switchTo()
      Specified by:
      switchTo in interface org.openqa.selenium.WebDriver
    • manage

      public org.openqa.selenium.WebDriver.Options manage()
      Specified by:
      manage in interface org.openqa.selenium.WebDriver
    • script

      public Script script()
    • network

      public Network network()
    • getElementConverter

      protected JsonToWebElementConverter getElementConverter()
    • setElementConverter

      protected void setElementConverter(JsonToWebElementConverter converter)
    • setLogLevel

      public void setLogLevel(Level level)
      Sets the RemoteWebDriver's client log level.
      Parameters:
      level - The log level to use.
    • execute

      protected Response execute(CommandPayload payload)
    • execute

      protected Response execute(String driverCommand, Map<String,?> parameters)
    • execute

      protected Response execute(String command)
    • getExecuteMethod

      protected ExecuteMethod getExecuteMethod()
    • perform

      @NullMarked public void perform(Collection<org.openqa.selenium.interactions.Sequence> actions)
      Specified by:
      perform in interface org.openqa.selenium.interactions.Interactive
    • resetInputState

      public void resetInputState()
      Specified by:
      resetInputState in interface org.openqa.selenium.interactions.Interactive
    • addVirtualAuthenticator

      @NullMarked public org.openqa.selenium.virtualauthenticator.VirtualAuthenticator addVirtualAuthenticator(org.openqa.selenium.virtualauthenticator.VirtualAuthenticatorOptions options)
      Specified by:
      addVirtualAuthenticator in interface org.openqa.selenium.virtualauthenticator.HasVirtualAuthenticator
    • removeVirtualAuthenticator

      @NullMarked public void removeVirtualAuthenticator(org.openqa.selenium.virtualauthenticator.VirtualAuthenticator authenticator)
      Specified by:
      removeVirtualAuthenticator in interface org.openqa.selenium.virtualauthenticator.HasVirtualAuthenticator
    • isDownloadsEnabled

      public boolean isDownloadsEnabled()
      Specified by:
      isDownloadsEnabled in interface org.openqa.selenium.HasDownloads
    • getDownloadableFiles

      @Deprecated public List<String> getDownloadableFiles()
      Deprecated.
      Use method getDownloadedFiles() instead
      Retrieves the names of the files downloaded by browser.
      Specified by:
      getDownloadableFiles in interface org.openqa.selenium.HasDownloads
      Returns:
      A list containing the names of the downloaded files.
      Throws:
      org.openqa.selenium.WebDriverException - if capability to enable downloads is not set
    • getDownloadedFiles

      public List<org.openqa.selenium.HasDownloads.DownloadedFile> getDownloadedFiles()
      Retrieves the list of files downloaded by browser.
      Specified by:
      getDownloadedFiles in interface org.openqa.selenium.HasDownloads
      Returns:
      A list containing the names, size etc. of the downloaded files.
      Throws:
      org.openqa.selenium.WebDriverException - if capability to enable downloads is not set
    • downloadFile

      public void downloadFile(String fileName, Path targetLocation) throws IOException
      Downloads a file from the specified location.
      Specified by:
      downloadFile in interface org.openqa.selenium.HasDownloads
      Parameters:
      fileName - the name of the file to download
      targetLocation - the location where the file should be downloaded
      Throws:
      IOException - if an I/O error occurs during the file download
    • deleteDownloadableFiles

      public void deleteDownloadableFiles()
      Deletes all downloadable files.
      Specified by:
      deleteDownloadableFiles in interface org.openqa.selenium.HasDownloads
      Throws:
      org.openqa.selenium.WebDriverException - capability to enable downloads must be set
    • fireSessionEvent

      public Map<String,Object> fireSessionEvent(String eventType, Map<String,Object> payload)
      Fires a custom session event to the remote server event bus. This allows test code to trigger server-side utilities that subscribe to the event bus.

      Example usage:

      
       // Simple event
       driver.fireSessionEvent("test:started");
      
       // Event with payload
       driver.fireSessionEvent("test:failed", Map.of(
           "testName", "LoginTest",
           "error", "Element not found"
       ));
       
      Parameters:
      eventType - the type of event (e.g., "test:failed", "log:collect", "marker:add")
      payload - optional data to include with the event (maybe null or empty)
      Returns:
      the response data from the server
      Throws:
      org.openqa.selenium.WebDriverException - if the event cannot be fired
    • fireSessionEvent

      public Map<String,Object> fireSessionEvent(String eventType)
      Fires a custom session event to the remote server event bus without a payload.
      Parameters:
      eventType - the type of event (e.g., "test:started", "log:collect")
      Returns:
      the response data from the server
      Throws:
      org.openqa.selenium.WebDriverException - if the event cannot be fired
      See Also:
    • setDelayEnabled

      public void setDelayEnabled(boolean enabled)
      Specified by:
      setDelayEnabled in interface org.openqa.selenium.federatedcredentialmanagement.HasFederatedCredentialManagement
    • resetCooldown

      public void resetCooldown()
      Specified by:
      resetCooldown in interface org.openqa.selenium.federatedcredentialmanagement.HasFederatedCredentialManagement
    • getFederatedCredentialManagementDialog

      public org.openqa.selenium.federatedcredentialmanagement.FederatedCredentialManagementDialog getFederatedCredentialManagementDialog()
      Specified by:
      getFederatedCredentialManagementDialog in interface org.openqa.selenium.federatedcredentialmanagement.HasFederatedCredentialManagement
    • log

      protected void log(SessionId sessionId, String commandName, Object toLog, RemoteWebDriver.When when)
      Override this to be notified at key points in the execution of a command.
      Parameters:
      sessionId - the session id.
      commandName - the command that is being executed.
      toLog - any data that might be interesting.
      when - verb tense of "Execute" to prefix message
    • getFileDetector

      public FileDetector getFileDetector()
    • setFileDetector

      public void setFileDetector(FileDetector detector)
      Set the file detector to be used when sending keyboard input. By default, this is set to a file detector that does nothing.
      Parameters:
      detector - The detector to use. Must not be null.
      See Also:
    • toString

      public String toString()
      Overrides:
      toString in class Object