Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add sendkeys method in T2C runner and support input keys directly #157

Merged
merged 5 commits into from
Nov 22, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -57,7 +57,6 @@ public static void chooseActionType(BaseDriverController driver, ActionInfo acti
BaseElementInfo element = actionInfo.getTestElement();
WebElement webElement = findElement(driver, element);
Map<String, Object> arguments = actionInfo.getArguments();

switch (ActionType) {
case "click":
driver.click(webElement);
Expand All @@ -78,7 +77,11 @@ public static void chooseActionType(BaseDriverController driver, ActionInfo acti
if (content == null) {
throw new IllegalArgumentException("Trying to input a null String. actionId: " + actionInfo.getId());
}
driver.input(webElement, content);
if (webElement == null) {
driver.sendKeys(content);
} else {
driver.input(webElement, content);
}
break;
case "clear":
driver.clear(webElement);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@
import org.openqa.selenium.Point;
import org.openqa.selenium.WebDriver;
import org.openqa.selenium.WebElement;
import org.openqa.selenium.interactions.Actions;
import org.openqa.selenium.support.ui.ExpectedCondition;
import org.openqa.selenium.support.ui.WebDriverWait;
import org.slf4j.Logger;
Expand All @@ -27,6 +28,14 @@ public void click(WebElement element) {
element.click();
}

/**
* Send content via keyboard, this will send the string directly to the current focus element
* @param content string you want to input with
*/
public void sendKeys(String content) {
new Actions(webDriver).sendKeys(content).perform();
}

public void tap(int x, int y) {
}

Expand Down Expand Up @@ -156,4 +165,5 @@ public WebElement findElementByName(String name) {
}
return elementFound;
}

}
Original file line number Diff line number Diff line change
Expand Up @@ -43,4 +43,5 @@ public void tap(int x, int y) {
tap.addAction(finger.createPointerUp(PointerInput.MouseButton.LEFT.asArg()));
windowsDriver.perform(Arrays.asList(tap));
}

}
14 changes: 13 additions & 1 deletion taps_to_cases/T2C_Runner/src/test/resources/DemoJson.json
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,18 @@
}
},
"isOption": false
}
},
{
"index": 1,
"elementInfo": { },
"driverId": "13211FDD400183",
"action": {
"actionType": "input",
"arguments": {
"content": "helloworld"
}
},
"isOption": false
}
]
}