- android - 多次调用 OnPrimaryClipChangedListener
- android - 无法更新 RecyclerView 中的 TextView 字段
- android.database.CursorIndexOutOfBoundsException : Index 0 requested, 光标大小为 0
- android - 使用 AppCompat 时,我们是否需要明确指定其 UI 组件(Spinner、EditText)颜色
我正在尝试使用 Eclipse Luna 在 Safari 上使用 Selenium 测试我的网站。
我的网站使用 Twitter 登录。
当我尝试将 key 发送到 api.twitter.com 上的输入时,出现超时。
请注意,我已经尝试使用 Selenium 的 wiki 页面在 google 上“发送 key ”,甚至在 www.twitter.com 上也运行良好。
我不明白为什么它在 api.twitter.com 上不起作用。
我以为问题出在我的网站上,然后我在另一个也使用 Twitter 身份验证的网站上测试了相同的代码,并且出现了相同的错误。
我什至尝试使用 javascriptExecutor 来填充输入的值,但我也遇到了超时。
有人可以帮我吗?
请在下面找到我的代码和控制台中的跟踪。
package com.fxlabs.wonderboard.nodeTest;
import static org.junit.Assume.assumeTrue;
import org.openqa.selenium.By;
import org.openqa.selenium.Platform;
import org.openqa.selenium.WebDriver;
import org.openqa.selenium.WebElement;
import org.openqa.selenium.safari.SafariDriver;
import org.openqa.selenium.support.ui.ExpectedConditions;
import org.openqa.selenium.support.ui.WebDriverWait;
import org.junit.After;
import org.junit.Before;
import org.junit.Test;
import org.junit.runner.RunWith;
import org.junit.runners.JUnit4;
@RunWith(JUnit4.class)
public class BrowserTest {
private WebDriver driver = null;
private static boolean isSupportedPlatform() {
Platform current = Platform.getCurrent();
return Platform.MAC.is(current) || Platform.WINDOWS.is(current);
}
@Before
public void createDriver() {
assumeTrue(isSupportedPlatform());
driver = new SafariDriver();
}
@After
public void quitDriver() {
driver.quit();
}
@Test
public void shouldBeAbleToPerformAGoogleSearch() {
driver.get("http://tweetbeam.com");
new WebDriverWait(driver, 3).until(ExpectedConditions.titleIs("TweetBeam Twitter Wall - Visualize Live Tweets"));
driver.findElement(By.className("navbar-right")).findElement(By.tagName("a")).click();
new WebDriverWait(driver, 3).until(ExpectedConditions.titleIs("Twitter / Autoriser une application"));
driver.findElement(By.id("username_or_email")).sendKeys("TwitterUsername");
driver.findElement(By.id("username_or_email")).sendKeys("password");
}
}
故障追踪:
org.openqa.selenium.TimeoutException: Timed out awaiting response to command "sendKeysToElement" after 30001 ms (WARNING: The server did not provide any stacktrace information)
Command duration or timeout: 30.01 seconds
Build info: version: '2.44.0', revision: '76d78cf323ce037c5f92db6c1bba601c2ac43ad8', time: '2014-10-23 13:11:40'
System info: host: 'xxx', ip: 'xxx', os.name: 'Mac OS X', os.arch: 'x86_64', os.version: '10.9.5', java.version: '1.6.0_65'
Session ID: null
Driver info: org.openqa.selenium.safari.SafariDriver
Capabilities [{platform=MAC, cssSelectorsEnabled=true, javascriptEnabled=true, secureSsl=true, browserName=safari, takesScreenshot=true, version=7.1.4}]
at sun.reflect.NativeConstructorAccessorImpl.newInstance0(Native Method)
at sun.reflect.NativeConstructorAccessorImpl.newInstance(NativeConstructorAccessorImpl.java:39)
at sun.reflect.DelegatingConstructorAccessorImpl.newInstance(DelegatingConstructorAccessorImpl.java:27)
at java.lang.reflect.Constructor.newInstance(Constructor.java:513)
at org.openqa.selenium.remote.ErrorHandler.createThrowable(ErrorHandler.java:204)
at org.openqa.selenium.remote.ErrorHandler.throwIfResponseFailed(ErrorHandler.java:156)
at org.openqa.selenium.remote.RemoteWebDriver.execute(RemoteWebDriver.java:599)
at org.openqa.selenium.remote.RemoteWebElement.execute(RemoteWebElement.java:268)
at org.openqa.selenium.remote.RemoteWebElement.sendKeys(RemoteWebElement.java:89)
at com.fxlabs.wonderboard.nodeTest.BrowserTest.shouldBeAbleToPerformAGoogleSearch(BrowserTest.java:44)
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:39)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)
at java.lang.reflect.Method.invoke(Method.java:597)
at org.junit.runners.model.FrameworkMethod$1.runReflectiveCall(FrameworkMethod.java:50)
at org.junit.internal.runners.model.ReflectiveCallable.run(ReflectiveCallable.java:12)
at org.junit.runners.model.FrameworkMethod.invokeExplosively(FrameworkMethod.java:47)
at org.junit.internal.runners.statements.InvokeMethod.evaluate(InvokeMethod.java:17)
at org.junit.internal.runners.statements.RunBefores.evaluate(RunBefores.java:26)
at org.junit.internal.runners.statements.RunAfters.evaluate(RunAfters.java:27)
at org.junit.runners.ParentRunner.runLeaf(ParentRunner.java:325)
at org.junit.runners.BlockJUnit4ClassRunner.runChild(BlockJUnit4ClassRunner.java:78)
at org.junit.runners.BlockJUnit4ClassRunner.runChild(BlockJUnit4ClassRunner.java:57)
at org.junit.runners.ParentRunner$3.run(ParentRunner.java:290)
at org.junit.runners.ParentRunner$1.schedule(ParentRunner.java:71)
at org.junit.runners.ParentRunner.runChildren(ParentRunner.java:288)
at org.junit.runners.ParentRunner.access$000(ParentRunner.java:58)
at org.junit.runners.ParentRunner$2.evaluate(ParentRunner.java:268)
at org.junit.runners.ParentRunner.run(ParentRunner.java:363)
at org.eclipse.jdt.internal.junit4.runner.JUnit4TestReference.run(JUnit4TestReference.java:50)
at org.eclipse.jdt.internal.junit.runner.TestExecution.run(TestExecution.java:38)
at org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.runTests(RemoteTestRunner.java:459)
at org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.runTests(RemoteTestRunner.java:675)
at org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.run(RemoteTestRunner.java:382)
at org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.main(RemoteTestRunner.java:192)
最佳答案
您正在尝试将电子邮件和密码发送到同一字段,不是吗?
driver.FindElement(By.Id("username_or_email")).SendKeys("TwitterUsername");
driver.FindElement(By.Id("password")).SendKeys("password");
这对我来说效果很好。
但是请小心,因为如果页面检测到您已经登录 Twitter,其行为会有所不同。您会看到一个弹出窗口,其中有一些对话框欢迎您。
关于java - Selenium Safari 使用 findElement.sendkeys 超时,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/29692239/
其使用格式为: object.SendKeys string "object":表示WshShell对象 "string":表示要发送的按键指令字符串,需要放
如何使用命令 sendKeys(Keys.TAB) 和 sendKeys("text") 填写列中的几个字段。例如:页面底部的“联系我们”表单中有 3 个字段: 姓名 电子邮件 留言和“提交”按钮。
sendkeys(keys.Down) 和 sendkeys(keys.Arrow_Down) 之间有什么区别在 Selenium java中 最佳答案 没有区别,在以前版本的 selenium 中,
我的测试是在搜索文本框中输入键(主要是ajax),然后按键盘上的回车键。没有“开始”搜索的按钮,因此我们使用 Enter 键。 我使用 ChromeDriver,因为我们的应用程序在此流程中不支持 F
我试图在 sendKeys 方法 [type WebElement] 中将“String”作为参数发送,但系统将其用作 char 序列,所以我没有得到正确的输出。 public static
我想在新窗口中打开应用程序的链接。使用操作类在我当前所在的同一窗口中打开链接。 我尝试在多个应用程序的 Chrome 驱动程序和 Firefox 驱动程序上使用带有以下代码的 Actions 类,但没
据我所知,有两种使用 Selenium 进行输入的方法: new Actions(webDriver).sendKeys("text to send").perform(); webElement.s
我正在使用 Selenium 通过 VS Code 用 Java 进行编写。 我无法编译这行代码,因为 sendKeys 方法下有一条红线。 代码行是: driver.findElement(By
我正在使用以下过程作为 OnTime 方法的一部分: Public Sub Countdown() ThisWorkbook.Activate SendKeys ("{ESC}")
我是 VBA 的新手,我的研究表明我不应该使用 .SendKeys,因为它不可靠。我应该为以下使用什么替代代码? Application.SendKeys ("{Home}") 最佳答案 这看起来选择
我正在使用 .SendKeys()在 Excel VBA 中将击键发送到我正在使用 shell .AppActive 激活的外部窗口方法。问题是 SendKeys只是行为不一致,有时发送 key ,有
我正在使用 (new Actions(driver).sendKeys(String).perform() 将输入发送到 webdriver。但是,我一直得到不一致的结果。有时 String 会完美发
我用 Java 编写了脚本,它正在 Chrome 浏览器中运行。我有一个用户名字段、密码字段和一个登录按钮。甚至在完成用户名字段中的输入之前,它就开始在密码字段/登录按钮上执行操作。 这是我的代码,
我使用 sendkey 访问 Power Query 并连接到 SharePoint 文件夹。一切都很顺利,直到出现 Power Query 数据预览对话框。 如何允许 sendkey 在对话框出现后
我在输入一些特殊字符时遇到了一些问题 SendKey.Send("~!@#$%^&*()_+|") . 当我尝试输入 ~!@#$%^&*()_+| 时, 只有 !@#$*_|已输入。 有办法解决这个问
我创建了一个键盘应用程序,它保持在顶部,但不获取焦点,因此在触摸屏上它会通过 SendKeys 将您按下的任何键转发到事件应用程序。 它与我尝试过的每个应用程序都完美配合……当然,除了我实际需要它使用
我正在尝试使用 sendkeys,但将它发送到一个非焦点程序。例如,我想使用 sendkeys 到 Notepad - Untitled,但它没有被聚焦。抱歉,如果不清楚,我会详细说明。我当前的代码是
我希望我的 C# 程序在继续之前关闭某个遗留应用程序。使用 ctrl+x 可以立即关闭旧版应用程序。我可以使用 Sendkeys 来做到这一点,但我听说 sendkeys 可能有点不稳定。有没有其他方
您好,我已经在 login-page.js 中编写了这段代码 我不知道为什么会出现错误 失败:无法读取未定义的属性“sendKeys” 我在 login_spec.js 上调用了这个页面 我无法在 P
我在表单中有两个输入字段,它们的来源在下面提到 我正在尝试在 selenium 网络驱动程序 (Firefox) 中使用以下命令发送输入 driver.findElement(By.cssSele
我是一名优秀的程序员,十分优秀!