TLDR:
sendKeys()
在Web应用程序文本字段中无效,仅在IOSDriver / XCUITest上有效,并且仅在我的Web应用程序页面上有效。在Android模拟器中运行相同的测试时,它在我的页面以及我测试过的所有其他地方(google和ask.com搜索输入)都可以正常工作,但是当我在iOS模拟器中测试时,sendKeys()
不能正常工作可以在我的Web应用程序的页面上工作,但可以在其他地方(google和ask.com)工作,我也不知道为什么。
功能配置文件:
["Safari", "12.2", "iOS", "iPhone Simulator", "XCUITest", "1.12.1"]
测试:
public class AppiumFieldsTest extends TestBase {
@Test(dataProvider = "appium", groups = "Appium", description = "appium fields test")
public void appiumFieldsTest(String browser, String version, String platform, String device, Method method, String automationName, String appiumVersion) throws Exception {
IOSDriver<WebElement> driver;
DesiredCapabilities caps = new DesiredCapabilities();
caps.setCapability(MobileCapabilityType.PLATFORM_NAME, platform);
caps.setCapability(MobileCapabilityType.PLATFORM_VERSION, version);
caps.setCapability(MobileCapabilityType.DEVICE_NAME, device);
caps.setCapability(MobileCapabilityType.AUTOMATION_NAME, automationName);
caps.setCapability(MobileCapabilityType.BROWSER_NAME, browser);
caps.setCapability("autoAcceptAlerts", true);
caps.setCapability("connectHardwareKeyboard", false);
caps.setCapability("sendKeyStrategy", "oneByOne");
System.out.println(caps);
String url = "http://127.0.0.1:4723/wd/hub";
driver = new IOSDriver(new URL(url), caps);
driver.manage().timeouts().implicitlyWait(2, TimeUnit.SECONDS);
driver.get("https://dev-app.pactsafe.com/sign?r=5cd32b47e89fc12f110449ca&s=5b2a6a597a7a3c1e4fa39c0b&signature=kto0Xohrz52ss7kc5z6t0grRbzUPsg6TrfbCbKtRuC5nQM82lNEhFL-zPgN7LaTvGG8mhuifNSc0nayvch1Rgc858Ptx8yRRD9MWJSoD4mEuHFg7LmJ-FHP~UsVEypv-gwwy-6N14BnhdkN94OZ73Kq9mBfS8QGlYKTqa76uclW0FIdnclRfA8NvK0z8CxjPcA8Luv9orw6Ye7wEuHAGqhqFURa15WeFrjrFKW9PNf6NkLVURNvOwqH4xBsfJubCkETMfjtnD4xT7PFSpgykAuU-Av0HehxCFNCYaHmyj5qvB3l9h7xgm8KKoSOO0c9VH1HpnLtwG6KAwwItawcsjg__");
String textFieldtext = "some random text";
Thread.sleep(10000);
WebElement ele = driver.findElementByXPath("//*[@data-name=\"field-5b6305f656bcff936a3c53ca\"]");
ele.click();
Thread.sleep(3000);
ele.sendKeys(textFieldtext);
Assert.assertEquals(ele.getAttribute("data-value"), textFieldtext);
...
...
...
我正在尝试在页面顶部的第一个字段中执行.click()
,然后执行.sendKeys()
,但是它没有发送任何文本。如果运行测试,则可以看到实际上已单击该字段,因为它按预期变成了较深的蓝色,但是随后sendKeys()
函数什么也不做。另外,在Android上进行测试时,键盘会在click()
上打开,但在iOS上不会打开。
sendKeyStratey
功能,但仍然没有尝试。 connectHardwareKeyboard
设置为true
以及false
,但结果仍然相同。Thread.sleep()
-nuthin appium日志显示,它确实在成功找到元素之后正在尝试发送文本:
[HTTP] {"id":"5000","text":"some random text","value":["s","o","m","e"," ","r","a","n","d","o","m"," ","t","e","x","t"]}
[W3C (bf5882ff)] Calling AppiumDriver.setValue() with args: [["s","o","m","e"," ","r","a","n","d","o","m"," ","t","e","x","t"],"5000","bf5882ff-f1a1-4ce1-bb79-02836762cb88"]
[XCUITest] Executing command 'setValue'
任何人和所有帮助/建议都将不胜感激
答案 0 :(得分:0)
您可以尝试使用以下选项之一: