网址' / wd / hub / session // moveto'没有映射到有效的资源

时间:2016-09-14 14:50:59

标签: selenium selenium-webdriver automated-tests appium ui-automation

我正在尝试使用AppiumDriver单击混合应用程序中的元素,使用下面的代码

AppiumDriver<IWebElement> driver = new AndroidDriver<IWebElement>(new Uri(serverUri), capabilities, TimeSpan.FromSeconds(Constants.DriverWaitTime));

driver.FindElement(By.Id("xyz")).Click();

//这会出错。元素不可点击,因为其他元素会收到点击。

由于这个原因,我尝试使用Action类(每次都不成功)

private static Actions actions = new Actions(Client.AppiumDriver);
private static IWebElement element = null;

element = Client.AppiumDriver.FindElement(By.Id(locator));
actions.MoveToElement(element, 10, 10).Click().Perform();

但似乎Action类不可靠,

50%的时间操作会导致投掷错误&#34;网址&#39; / wd / hub / session // moveto&#39;未映射到有效资源&#34;

我试过等待,让元素完全加载,但我仍然遇到错误

有没有人遇到过类似的问题?如果是,那么请帮助。

这是Appium日志

[HTTP] <-- GET /wd/hub/session/9aaf70d4-8384-4c54-8386-62e40a3edea7/element/5017/enabled 200 515 ms - 76 
[HTTP] --> POST /wd/hub/session/9aaf70d4-8384-4c54-8386-62e40a3edea7/element {"using":"id","value":"hp_takePhoto"}
[MJSONWP] Calling AppiumDriver.findElement() with args: ["id","hp_takePhoto","9aaf70d4-8384-4c54-8386-62e40a3edea7"]
[debug] [iOS] Executing iOS command 'findElement'
[debug] [BaseDriver] Waiting up to 5000 ms for condition
[debug] [RemoteDebugger] Executing 'find_element' atom in default context
[debug] [RemoteDebugger] Sending javascript command (function(){return function...
[debug] [RemoteDebugger] Sending WebKit data: {"method":"Runtime.evaluate...
[debug] [RemoteDebugger] Receiving WebKit data: {"result":{"result":{"type"...
[debug] [RemoteDebugger] Found handler for message '42'
[debug] [RemoteDebugger] Received result for atom 'find_element' execution: {"ELEMENT":":wdc:1474455901436"}
[MJSONWP] Responding to client with driver.findElement() result: {"ELEMENT":"5018"}
[HTTP] <-- POST /wd/hub/session/9aaf70d4-8384-4c54-8386-62e40a3edea7/element 200 514 ms - 90 
[HTTP] --> POST /wd/hub/session//moveto {"element":"5018","xoffset":10,"yoffset":10}
[debug] [HTTP] No route found. Setting content type to 'text/plain'
[HTTP] <-- POST /wd/hub/session//moveto 404 1 ms - 65

当步骤成功执行时,日志就像

[HTTP] --> POST /wd/hub/session/c3924633-053a-450b-a3fb-2600c00655c5/element {"using":"id","value":"hp_takePhoto"}
[MJSONWP] Calling AppiumDriver.findElement() with args: ["id","hp_takePhoto","c3924633-053a-450b-a3fb-2600c00655c5"]
[debug] [iOS] Executing iOS command 'findElement'
[debug] [BaseDriver] Waiting up to 5000 ms for condition
[debug] [RemoteDebugger] Executing 'find_element' atom in default context
[debug] [RemoteDebugger] Sending javascript command (function(){return function...
[debug] [RemoteDebugger] Sending WebKit data: {"method":"Runtime.evaluate...

[debug] [RemoteDebugger] Receiving WebKit data: {"result":{"result":{"type"...
[debug] [RemoteDebugger] Found handler for message '30'
[debug] [RemoteDebugger] Received result for atom 'find_element' execution: {"ELEMENT":":wdc:1474457829048"}

[MJSONWP] Responding to client with driver.findElement() result: {"ELEMENT":"5012"}

[HTTP] <-- POST /wd/hub/session/c3924633-053a-450b-a3fb-2600c00655c5/element 200 511 ms - 90 

[HTTP] --> POST /wd/hub/session/c3924633-053a-450b-a3fb-2600c00655c5/execute {"script":"arguments[0].click()","args":[{"ELEMENT":"5012","element-6066-11e4-a52e-4f735466cecf":"5012"}]}

[MJSONWP] Calling AppiumDriver.execute() with args: ["arguments[0].click()",[{"ELEMENT":"5012","element-6066-11e4-a52e-4f735466cecf":"5012"}],"c3924633-053a-450b-a3fb-2600c00655c5"]
[debug] [iOS] Executing iOS command 'execute'
[debug] [RemoteDebugger] Executing 'execute_script' atom in default context
[debug] [RemoteDebugger] Sending javascript command (function(){return function...
[debug] [RemoteDebugger] Sending WebKit data: {"method":"Runtime.evaluate...

[debug] [RemoteDebugger] Receiving WebKit data: {"result":{"result":{"type"...

[debug] [RemoteDebugger] Found handler for message '31'
[debug] [RemoteDebugger] Received result for atom 'execute_script' execution: null

[MJSONWP] Responding to client with driver.execute() result: null

[HTTP] <-- POST /wd/hub/session/c3924633-053a-450b-a3fb-2600c00655c5/execute 200 513 ms - 76 

0 个答案:

没有答案