Ios 在Appium中,我尝试使用xpath访问webview中的元素(点击按钮或编辑textfield中的文本)。但我做不到

Ios 在Appium中,我尝试使用xpath访问webview中的元素(点击按钮或编辑textfield中的文本)。但我做不到,ios,xpath,acceptance-testing,appium-ios,Ios,Xpath,Acceptance Testing,Appium Ios,在Appium中,我尝试访问I.e点击按钮或使用XPath编辑web视图中文本字段元素中的文本。但我能够访问本机元素,而不是webview元素 我使用Appium检查器获取XPath 上下文是本机的,因为当切换到WEBVIEW时,我发现HTML解析错误 XPATH : "//XCUIElementTypeOther[@name='Scripts: Responsive IFrames for embedding webpages']/XCUIElementTypeOther[8]/XCUIEle

在Appium中,我尝试访问I.e点击按钮或使用XPath编辑web视图中文本字段元素中的文本。但我能够访问本机元素,而不是webview元素

我使用Appium检查器获取XPath

上下文是本机的,因为当切换到WEBVIEW时,我发现HTML解析错误

XPATH : "//XCUIElementTypeOther[@name='Scripts: Responsive IFrames for embedding webpages']/XCUIElementTypeOther[8]/XCUIElementTypeTextView"



    /Users/dxcdr/.rvm/gems/ruby-2.2.6/gems/appium_lib_core-1.5.1/lib/appium_lib_core/common/wait.rb:96:in `until_true': timed out after 60 seconds (Error Domain=com.facebook.WebDriverAgent Code=1 "The element '"Click to select all (also copies in IE)" Button' is not visible on the screen and thus is not interactable" UserInfo={NSLocalizedDescription=The element '"Click to select all (also copies in IE)" Button' is not visible on the screen and thus is not interactable}) (Appium::Core::Wait::TimeoutError)
        from /Users/dxcdr/.rvm/gems/ruby-2.2.6/gems/appium_lib_core-1.5.1/lib/appium_lib_core/common/wait.rb:127:in `wait_true'
        from /Users/dxcdr/.rvm/gems/ruby-2.2.6/gems/appium_lib-9.12.0/lib/appium_lib/common/wait.rb:26:in `wait_true'
        from /Users/dxcdr/RubymineProjects/Test/test.rb:53:in `wait_for_xpath_visible'
        from /Users/dxcdr/RubymineProjects/Test/test.rb:88:in `<top (required)>'
        from -e:1:in `load'
        from -e:1:in `<main>'
您的定位器类似于本机上下文,而不是web视图中的html元素,例如XUIElementTypeOther与web视图元素无关

您必须切换到web视图才能在其中搜索:

web|view|u context=可用的|context.find{c|c.start|u with?'WEBVIEW'}

设置上下文web\u视图\u上下文

使用g检查webview中的元素
幸运的是,Appium桌面1.6版已经发布。现在我可以通过本机上下文访问webview元素。谢谢@dmle