Skip to content

Commit cc8e452

Browse files
authored
Remove 'personality' and 'pluginClass' from caps (#276)
1 parent 04b445a commit cc8e452

File tree

4 files changed

+28
-14
lines changed

4 files changed

+28
-14
lines changed

src/main/java/com/nordstrom/automation/selenium/core/GridUtility.java

Lines changed: 23 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -36,6 +36,7 @@
3636
import org.apache.http.entity.StringEntity;
3737
import org.apache.http.impl.client.HttpClientBuilder;
3838
import org.openqa.selenium.Capabilities;
39+
import org.openqa.selenium.MutableCapabilities;
3940
import org.openqa.selenium.WebDriver;
4041
import org.openqa.selenium.remote.RemoteWebDriver;
4142
import org.slf4j.Logger;
@@ -162,9 +163,30 @@ public static WebDriver getDriver(URL remoteAddress, Capabilities desiredCapabil
162163
// get constructor for RemoteWebDriver class corresponding to desired capabilities
163164
Constructor<RemoteWebDriver> ctor = getRemoteWebDriverCtor(config, desiredCapabilities);
164165

166+
Map<String, Object> capsMap = new HashMap<>(desiredCapabilities.asMap());
167+
168+
// if capabilities contain 'nord:options'
169+
if (capsMap.containsKey("nord:options")) {
170+
// get map of custom options from capabilities
171+
Map<String, Object> options = getNordOptions(desiredCapabilities);
172+
// remove 'personality'
173+
options.remove("personality");
174+
// remove 'pluginClass'
175+
options.remove("pluginClass");
176+
// if options are empty
177+
if (options.isEmpty()) {
178+
// remove 'nord:options'
179+
capsMap.remove("nord:options");
180+
// otherwise (non-empty)
181+
} else {
182+
// update 'nord:options'
183+
capsMap.put("nord:options", options);
184+
}
185+
}
186+
165187
try {
166188
// instantiate desired driver via configured grid
167-
return ctor.newInstance(remoteAddress, desiredCapabilities);
189+
return ctor.newInstance(remoteAddress, new MutableCapabilities(capsMap));
168190
} catch (InstantiationException | IllegalAccessException | IllegalArgumentException | InvocationTargetException e) {
169191
throw UncheckedThrow.throwUnchecked(e);
170192
}

src/main/java/com/nordstrom/automation/selenium/model/ContainerMethodInterceptor.java

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -130,11 +130,11 @@ public Object intercept(@This final Object obj, @Origin final Method method, @Al
130130
// if expecting page without load logic
131131
if (returnsPage && !detectsCompletion) {
132132
try {
133-
// get stale wait reference element by CSS selector
134-
reference = driver.findElement(By.cssSelector("*"));
135-
} catch (WebDriverException e) {
136133
// get stale wait reference element by XPath
137134
reference = driver.findElement(By.xpath("/*"));
135+
} catch (WebDriverException e) {
136+
// get stale wait reference element by CSS selector
137+
reference = driver.findElement(By.cssSelector("*"));
138138
}
139139
}
140140

src/main/java/com/nordstrom/automation/selenium/model/RobustElementFactory.java

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -121,9 +121,9 @@ private static synchronized InstanceCreator getCreator(final WrapsContext contex
121121
}
122122

123123
try {
124-
reference = driver.findElement(By.cssSelector("*"));
125-
} catch (WebDriverException e) {
126124
reference = driver.findElement(By.xpath("/*"));
125+
} catch (WebDriverException e) {
126+
reference = driver.findElement(By.cssSelector("*"));
127127
}
128128

129129
Class<? extends WebElement> refClass = reference.getClass();

src/test/java/com/nordstrom/automation/selenium/android/AndroidTest.java

Lines changed: 0 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -13,14 +13,6 @@
1313
@InitialPage(AndroidPage.class)
1414
public class AndroidTest extends TestNgTargetRoot {
1515

16-
// private final String MY_PACKAGE = "com.example.myapplication";
17-
// private final String SETTINGS_ACTIVITY = ".SettingsActivity";
18-
19-
// private final String KEY_SIGNATURE = "signature";
20-
// private final String KEY_REPLY = "reply";
21-
// private final String KEY_SYNC = "sync";
22-
// private final String KEY_ATTACHMENT = "attachment";
23-
2416
@Test
2517
@TargetPlatform(ANDROID_NAME)
2618
public void testSearchActivity() {

0 commit comments

Comments
 (0)