Skip to content

Commit

Permalink
Fix NPE getting empty cap
Browse files Browse the repository at this point in the history
  • Loading branch information
martingrossmann committed Jun 11, 2024
1 parent 7a0e5cf commit 6b727ac
Showing 1 changed file with 8 additions and 4 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@
*/
package eu.tsystems.mms.tic.testframework.mobile.guielement;

import eu.tsystems.mms.tic.testframework.appium.AppiumCapabilityHelper;
import eu.tsystems.mms.tic.testframework.common.Testerra;
import eu.tsystems.mms.tic.testframework.internal.NameableChild;
import eu.tsystems.mms.tic.testframework.logging.Loggable;
Expand Down Expand Up @@ -47,7 +48,10 @@
*
* @author mgn
*/
public class CreateAppiumGuiElementAction extends AbstractFieldAction implements UiElementFinderFactoryProvider, Loggable {
public class CreateAppiumGuiElementAction extends AbstractFieldAction implements
UiElementFinderFactoryProvider,
Loggable,
AppiumCapabilityHelper {

public CreateAppiumGuiElementAction(Field field, AbstractPage declaringPage) {
super(field, declaringPage);
Expand Down Expand Up @@ -100,9 +104,9 @@ private String getAutomationEngine(WebDriver driver, Platform platform) {
IWebDriverManager instance = Testerra.getInjector().getInstance(IWebDriverManager.class);
Optional<WebDriverRequest> optional = instance.getSessionContext(driver).map(SessionContext::getWebDriverRequest);
if (optional.isPresent()) {
String automationEngine = optional.get().getCapabilities().getCapability(MobileCapabilityType.AUTOMATION_NAME).toString();
if (StringUtils.isNotBlank(automationEngine)) {
return automationEngine;
Object automationEngine = optional.get().getCapabilities().getCapability(getAppiumCap(MobileCapabilityType.AUTOMATION_NAME));
if (automationEngine != null && StringUtils.isNotBlank(automationEngine.toString())) {
return automationEngine.toString();
} else {
// Use default values for automation engine
switch (platform) {
Expand Down

0 comments on commit 6b727ac

Please sign in to comment.