Skip to content

Commit

Permalink
Remove 'browserName' capability from stereotype when using RelaySessi…
Browse files Browse the repository at this point in the history
…on (#14247)

* Remove 'browserName' capability from stereotype. We expect it to be present is SessionRequest

* Only remove 'browserName' when 'appium:app' is present

* Formatting file

---------

Co-authored-by: Diego Molina <[email protected]>
Co-authored-by: Diego Molina <[email protected]>
  • Loading branch information
3 people authored Jul 12, 2024
1 parent 82715b9 commit 9d6131f
Showing 1 changed file with 12 additions and 1 deletion.
Original file line number Diff line number Diff line change
Expand Up @@ -40,6 +40,7 @@
import java.util.logging.Logger;
import org.openqa.selenium.Capabilities;
import org.openqa.selenium.ImmutableCapabilities;
import org.openqa.selenium.MutableCapabilities;
import org.openqa.selenium.SessionNotCreatedException;
import org.openqa.selenium.WebDriverException;
import org.openqa.selenium.grid.data.CreateSessionRequest;
Expand All @@ -49,6 +50,7 @@
import org.openqa.selenium.internal.Debug;
import org.openqa.selenium.internal.Either;
import org.openqa.selenium.internal.Require;
import org.openqa.selenium.remote.CapabilityType;
import org.openqa.selenium.remote.Command;
import org.openqa.selenium.remote.Dialect;
import org.openqa.selenium.remote.DriverCommand;
Expand Down Expand Up @@ -146,7 +148,16 @@ public Either<WebDriverException, ActiveSession> apply(CreateSessionRequest sess
new SessionNotCreatedException(
"New session request capabilities do not " + "match the stereotype."));
}
capabilities = capabilities.merge(stereotype);

// remove browserName capability if 'appium:app' is present as it breaks appium tests when app
// is provided
// they are mutually exclusive
MutableCapabilities filteredStereotype = new MutableCapabilities(stereotype);
if (capabilities.getCapability("appium:app") != null) {
filteredStereotype.setCapability(CapabilityType.BROWSER_NAME, (String) null);
}

capabilities = capabilities.merge(filteredStereotype);
LOG.info("Starting session for " + capabilities);

try (Span span = tracer.getCurrentContext().createSpan("relay_session_factory.apply")) {
Expand Down

0 comments on commit 9d6131f

Please sign in to comment.