【发布时间】:2014-01-27 16:32:11
【问题描述】:
我是自动化测试的新手。我正在使用 twitter 作为学习 selenium 的测试网站。
我想创建一条新推文,为此我正在使用以下场景。我可以打开“新推文”弹出窗口,但仍然无法在其文本框中输入文本。请帮忙。
先决条件:登录 Twitter
- 单击屏幕右上角的按钮(用于创建新推文)。 弹出窗口打开
- 单击弹出窗口中的文本框输入文本。 光标在文本框中突出显示并启用保存按钮
- 输入一些文字
- 点击保存按钮
对我来说,它一直工作到第 2 点,之后它不会在文本框中输入文本
请参阅下面的代码:
String popUpHandle = driver.getWindowHandle();
driver.switchTo().window(popUpHandle);
driver.findElement(By.id("global-new-tweet-button")).click();
driver.findElement(By.xpath("(//button[@type='button'])[123]")).click();
driver.findElement(By.xpath("(//button[@type='button'])[123]")).sendKeys("test tweet");
driver.findElement(By.xpath("//button[@type='button'])[106]")).click();
【问题讨论】:
-
会抛出异常吗?