我是使用webdriver进行自动测试的新手.有人请检查我收到的原因
java.lang.NullPointerException
at SuccessfullHoverTestCib.testSuccessfullHoverTestCib
(SuccessfullHoverTestCib.java:29)
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at sun.reflect.NativeMethodAccessorImpl.invoke(Unknown Source)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(Unknown Source)
at java.lang.reflect.Method.invoke(Unknown Source).....
Run Code Online (Sandbox Code Playgroud)
我正在运行以下代码:
public class SuccessfullHoverTestCib {
private WebDriver driver;
private String baseUrl;
private StringBuffer verificationErrors = new StringBuffer();
@Before
public void setUp() throws Exception {
File pathToFirefoxBinary = new File("C:\\Documents and Settings\\chakarova\\Local Settings\\Application Data\\Mozilla Firefox\\firefox.exe");
FirefoxBinary firefoxbin = new FirefoxBinary(pathToFirefoxBinary);
WebDriver driver = new FirefoxDriver(firefoxbin,null);
baseUrl = "http://cibnew.sofia.ifao.net:7001/cib_web/web";
driver.manage().timeouts().implicitlyWait(30, TimeUnit.SECONDS);
}
@Test
public void testSuccessfullHoverTestCib() throws Exception {
driver.get(baseUrl);
driver.findElement(By.id("inputButton")).click();
driver.findElement(By.linkText("Hotels")).click();
driver.findElement(By.id("pageLink_57")).click();
}
@After …Run Code Online (Sandbox Code Playgroud) 我面临以下问题.我无法在iframe中输入文本编辑器中的文本:这是html:
<iframe class="cke_wysiwyg_frame cke_reset" frameborder="0" style="width: 100%; height: 100%;" aria-describedby="cke_39" title="??????? ???????? ?? ?????????? ?????,description1" src="" tabindex="0" allowtransparency="true">
<!DOCTYPE html>
<html lang="bg" dir="ltr">
<head>
<body class="cke_editable cke_editable_themed cke_contents_ltr" contenteditable="true" spellcheck="false">
<p>
<br>
</p>
</body>
</html>
</iframe>
Run Code Online (Sandbox Code Playgroud)
这是我到目前为止所做的,但测试成功通过,文本编辑器中没有写入任何文本.可能解决方案是使用Javascript执行程序,但我不熟悉它.
WaitTool.waitForElementPresent(Browser.instance, By.tagName("iframe"), 10);
WebElement iframe = Browser.instance.findElement(By.tagName("iframe"));
Browser.instance.switchTo().frame(iframe);
WebElement description=Browser.instance.findElement(By.xpath("//body[@class='cke_editable cke_editable_themed cke_contents_ltr']"));
description.click();
description.sendKeys("someText");
Browser.instance.switchTo().defaultContent();
Run Code Online (Sandbox Code Playgroud)
提前致谢!