- html - 出于某种原因,IE8 对我的 Sass 文件中继承的 html5 CSS 不友好?
- JMeter 在响应断言中使用 span 标签的问题
- html - 在 :hover and :active? 上具有不同效果的 CSS 动画
- html - 相对于居中的 html 内容固定的 CSS 重复背景?
我正在使用 maven 和 testNG 以及 Appium Desktop 构建示例 appium 框架。
我想构建并运行一个“简单测试”;只是为了确保在开始执行添加“页面对象”和 log4j 等复杂操作之前我拥有正确的“testNG 边界”
我创建了一个非常简单的测试,使用 Android 来执行拖放测试。
流程是从应用程序主菜单>点击 View >点击拖放>执行拖放
查看下面的菜单
现在我可以从主菜单中选择“ View ”,但无法从 View 菜单中点击拖放。我不断收到以下错误消息,据我所知,选择 View “看起来不错”的语法。
如果语法错误
TestNG代码
public class DragnDropTest {
static AndroidDriver<MobileElement> driver;
@BeforeTest
public AndroidDriver<MobileElement> initDriver() throws MalformedURLException{
DesiredCapabilities caps =new DesiredCapabilities();
caps.setCapability("deviceName", "JacquelineNexus5");
caps.setCapability("platformName", "Android");
caps.setCapability("platformVersion", "8.0");
caps.setCapability("automationName", "UiAutomator2");
caps.setCapability("appPackage", "com.example.android.apis");
caps.setCapability("appActivity", "ApiDemos");
driver = new AndroidDriver<MobileElement>(new URL("http://127.0.0.1:4723/wd/hub"), caps);
driver.manage().timeouts().implicitlyWait(60, TimeUnit.SECONDS);
return driver;
}
@Test
//Scenario: Perform Drag n drop function
//Given I am on the Home screen
//When I tap the 'Views' menu item
//Then I will see the Views menu
//When I am in the 'view menu' I will select 'drag n drop'
//Then I will see 4 dots in the drag n drop page
//When I select the 1st dot and drag it
//Then I will drop it on the dot below
public void DragAndDrop(){
// tap Views from main menu
driver.findElementsById("android:id/text1").get(11).click();
driver.manage().timeouts().implicitlyWait(60, TimeUnit.SECONDS);
TouchAction t = new TouchAction (driver);
//Tap Drag and drop from Views Menu
t.tap(driver.findElementByXPath("//android.widget.EditText[@index= '8']")).perform();
t.longPress(driver.findElementById("io.appium.android.apis:id/drag_dot_1")).
moveTo(driver.findElementById("io.appium.android.apis:id/drag_dot_3")).release().perform();
}
}
Eclipse 控制台消息
[RemoteTestNG] detected TestNG version 6.11.0
Aug 20, 2018 12:17:26 PM org.openqa.selenium.remote.ProtocolHandshake createSession
INFO: Detected dialect: OSS
FAILED: DragAndDrop
org.openqa.selenium.NoSuchElementException: An element could not be located on the page using the given search parameters. (WARNING: The server did not provide any stacktrace information)
Command duration or timeout: 0 milliseconds
For documentation on this error, please visit: http://seleniumhq.org/exceptions/no_such_element.html
Build info: version: '3.6.0', revision: '6fbf3ec767', time: '2017-09-27T15:28:36.4Z'
System info: host: 'XXX-MacBook-Air.local', ip: '00.00.0.00', os.name: 'Mac OS X', os.arch: 'x86_64', os.version: '10.13.6', java.version: '1.8.0_71'
Driver info: io.appium.java_client.android.AndroidDriver
Capabilities [{appPackage=com.example.android.apis, deviceScreenSize=1080x1920, networkConnectionEnabled=true, statBarHeight=63, warnings={}, viewportRect={top=63, left=0, width=1080, height=1731}, databaseEnabled=false, deviceName=emulator-5554, platform=LINUX, deviceUDID=emulator-5554, appActivity=ApiDemos, desired={appActivity=ApiDemos, appPackage=com.example.android.apis, platformVersion=8.0, automationName=UiAutomator2, platformName=Android, deviceName=JacquelineNexus5}, platformVersion=8.0.0, pixelRatio=2.625, webStorageEnabled=false, locationContextEnabled=false, automationName=UiAutomator2, takesScreenshot=true, javascriptEnabled=true, deviceScreenDensity=420, deviceModel=Android SDK built for x86, deviceManufacturer=Google, deviceApiLevel=26, platformName=LINUX}]
Session ID: c2726815-8435-4b3d-b3c8-92f6845c616b
*** Element info: {Using=xpath, value=//android.widget.EditText[@index= '8']}
at sun.reflect.NativeConstructorAccessorImpl.newInstance0(Native Method)
at sun.reflect.NativeConstructorAccessorImpl.newInstance(NativeConstructorAccessorImpl.java:62)
at sun.reflect.DelegatingConstructorAccessorImpl.newInstance(DelegatingConstructorAccessorImpl.java:45)
at java.lang.reflect.Constructor.newInstance(Constructor.java:422)
at org.openqa.selenium.remote.ErrorHandler.createThrowable(ErrorHandler.java:214)
at org.openqa.selenium.remote.ErrorHandler.throwIfResponseFailed(ErrorHandler.java:166)
at org.openqa.selenium.remote.http.JsonHttpResponseCodec.reconstructValue(JsonHttpResponseCodec.java:40)
at org.openqa.selenium.remote.http.AbstractHttpResponseCodec.decode(AbstractHttpResponseCodec.java:80)
at org.openqa.selenium.remote.http.AbstractHttpResponseCodec.decode(AbstractHttpResponseCodec.java:44)
at org.openqa.selenium.remote.HttpCommandExecutor.execute(HttpCommandExecutor.java:158)
at io.appium.java_client.remote.AppiumCommandExecutor.execute(AppiumCommandExecutor.java:89)
at org.openqa.selenium.remote.RemoteWebDriver.execute(RemoteWebDriver.java:545)
at io.appium.java_client.DefaultGenericMobileDriver.execute(DefaultGenericMobileDriver.java:42)
at io.appium.java_client.AppiumDriver.execute(AppiumDriver.java:1)
at io.appium.java_client.android.AndroidDriver.execute(AndroidDriver.java:1)
at org.openqa.selenium.remote.RemoteWebDriver.findElement(RemoteWebDriver.java:319)
at io.appium.java_client.DefaultGenericMobileDriver.findElement(DefaultGenericMobileDriver.java:62)
at io.appium.java_client.AppiumDriver.findElement(AppiumDriver.java:1)
at io.appium.java_client.android.AndroidDriver.findElement(AndroidDriver.java:1)
at org.openqa.selenium.remote.RemoteWebDriver.findElementByXPath(RemoteWebDriver.java:421)
at io.appium.java_client.DefaultGenericMobileDriver.findElementByXPath(DefaultGenericMobileDriver.java:140)
at io.appium.java_client.AppiumDriver.findElementByXPath(AppiumDriver.java:1)
at io.appium.java_client.android.AndroidDriver.findElementByXPath(AndroidDriver.java:1)
at android.DragnDropTest.DragAndDrop(DragnDropTest.java:71)
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
at java.lang.reflect.Method.invoke(Method.java:497)
at org.testng.internal.MethodInvocationHelper.invokeMethod(MethodInvocationHelper.java:108)
at org.testng.internal.Invoker.invokeMethod(Invoker.java:661)
at org.testng.internal.Invoker.invokeTestMethod(Invoker.java:869)
at org.testng.internal.Invoker.invokeTestMethods(Invoker.java:1193)
at org.testng.internal.TestMethodWorker.invokeTestMethods(TestMethodWorker.java:126)
at org.testng.internal.TestMethodWorker.run(TestMethodWorker.java:109)
at org.testng.TestRunner.privateRun(TestRunner.java:744)
at org.testng.TestRunner.run(TestRunner.java:602)
at org.testng.SuiteRunner.runTest(SuiteRunner.java:380)
at org.testng.SuiteRunner.runSequentially(SuiteRunner.java:375)
at org.testng.SuiteRunner.privateRun(SuiteRunner.java:340)
at org.testng.SuiteRunner.run(SuiteRunner.java:289)
at org.testng.SuiteRunnerWorker.runSuite(SuiteRunnerWorker.java:52)
at org.testng.SuiteRunnerWorker.run(SuiteRunnerWorker.java:86)
at org.testng.TestNG.runSuitesSequentially(TestNG.java:1301)
at org.testng.TestNG.runSuitesLocally(TestNG.java:1226)
at org.testng.TestNG.runSuites(TestNG.java:1144)
at org.testng.TestNG.run(TestNG.java:1115)
at org.testng.remote.AbstractRemoteTestNG.run(AbstractRemoteTestNG.java:114)
at org.testng.remote.RemoteTestNG.initAndRun(RemoteTestNG.java:251)
at org.testng.remote.RemoteTestNG.main(RemoteTestNG.java:77)
最佳答案
如果您看到 appium 服务器日志,它表示根据传递的定位器未找到元素
org.openqa.selenium.NoSuchElementException: An element could not be located on the page using the given search parameters. (WARNING: The server did not provide any stacktrace information) Command duration or timeout: 0 milliseconds
由于您已经在测试中添加了 60 秒隐式等待,但 appium 不接受它,因此您必须在代码中传递以下功能。
caps.setCapability("newCommandTimeout", "2000");
注意 - 确保您的 xpath 正确。
我还有一个建议,您可以在此处查看用于拖放的官方 appium 单元测试功能
关于java - Appium TestNG 测试 : Unable to select from secondary Menu list: NoSuchElementException,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/51929746/
解释 onCreateOptionsMenu(Menu menu) 和 onPrepareOptionsMenu(Menu menu) 的区别。 最佳答案 onCreateOptionsMenu()
所以我又一次为一些问题而苦苦挣扎。这次是这样的,当我将鼠标悬停在 portfoilio 的下拉菜单上时(当网站处于移动 View 模式时),它只会越过其他元素,我尝试使所有内容相对,删除 float
我正在为移动设备设置新菜单。一切都设置好了,但在我点击任何菜单项后,它并没有关闭菜单和菜单覆盖。 有什么办法解决这个问题吗? 我在下面提供了我的 CSS 和 HTML 代码。 CSS margin
我正在使用 selenium webdriver 为单页 Web 应用程序开发一个 Java 框架,使用以下模式:PageObject、SlowLoadableComponent(责任链)、PageF
我是一个动态创建和选项菜单,选项菜单取决于 onCreate() 阶段创建的数据。 问题在于 onCreateOptionsMenu() 在创建数据之前被调用。有没有办法在onCreate()之后执行
HTML: Portfolio Services About Testimonials Request a Quote CSS: ul#menu li {
我是 extjs 的新手。我想在从 Ext.menu.Menu 选择菜单项时关联一个商店。我正在使用 extjs 4.1.0。我在网上搜索甚至通过 sencha doc 但我找不到任何方法来实现这一目
我正在使用 Bootstrap 3.0.0 制作网站 除了下拉菜单不起作用之外,一切都很好。 在文件的头部,我做出了以下声明: 有什么东西不见了? html 应该是正确的:
我刚刚开始学习 JQuery/JavaScript,我无法弄清楚使用 (".menu") 和 ("menu") 之间的区别以及应该在哪里使用它们? 最佳答案 它是menue,jquery使用css选择
我正在尝试向我的应用程序页面之一添加菜单,但由于某种原因,它没有出现。我使这个特定页面扩展了 AppCompactActivity 并覆盖了 onCreateOptionsMenu(Menu menu
我需要完全控制透视菜单。 我已经侵入平台以禁用上下文菜单: private void disablePerspectiveToolbarMenu() { PerspectiveBarManag
假设我有一个包含一些项目的菜单 (Ext.menu.Menu)。显示菜单时,用户 cat 右键单击它的项目,将显示浏览器上下文菜单(带有“将链接另存为...”等元素)。 如何禁用该浏览器上下文菜单
我有一个按钮,单击后将展开一个菜单项,我希望能够通过 java 脚本控制台以编程方式单击其中一个菜单项。这是我单击按钮所需的内容,但在单击 Ext.menu.Menu 时需要一些帮助 var fire
关闭。这个问题不符合Stack Overflow guidelines .它目前不接受答案。 我们不允许提出有关书籍、工具、软件库等建议的问题。您可以编辑问题,以便可以用事实和引用来回答它。 5年前关
在这里,我正在从事 safari 扩展开发。我已经在 safari 浏览器上成功获得了开发者证书。 在这里,我可以在工具栏项上创建菜单和子菜单,但根据我的项目要求,我必须在栏中包含菜单和菜单项。 请建
我正在使用 Java 和 Android Studio。我需要更改操作栏上的图像。我需要做的是根据从远程传感器接收到的读数来更改在操作栏上显示的图像。因此,我无法使用可点击的方法,而是使用一些代码在从
亲爱的..我有一个问题。在 Firebug 展上: $("#menu ul.menu").lavaLamp 不是 menu.js 中的函数 悬停在菜单上不显示。我把这个问题显示出来:
因此,我接到了一项任务,即使用 CSS 为网页创建一个汉堡包式多级菜单。这里的问题是添加一个子菜单,使其成为一个多层次的汉堡包。下面是我到目前为止为汉堡包多级菜单编写的代码片段 body { marg
我正在学习 Android 并遵循简单的相机应用教程。我复制了一段代码,但出现错误,我不确定原因。 我使用的教程是, http://iwearshorts.com/blog/android-devel
我的/About 中有一个包含路线的子菜单。 这个子菜单称为 AboutMenu 并出现在/About 下的所有页面,例如 =>/About/Company 和/About/Info。 练习示例显示
我是一名优秀的程序员,十分优秀!