public void File() throws Exception{ Thread.sleep(2000); //更改JS String js = "document.getElementsByClassName('update-avator')[0].style.bottom='0px';"; Thread.sleep(2000); JavascriptExecutor jsExecutor = (JavascriptExecutor) driver; Thread.sleep(2000); jsExecutor.executeScript(js); Thread.sleep(2000); driver.findElement(By.className("js-avator-link")).click(); Thread.sleep(2000); driver.findElement(By.id("upload")).sendKeys("C:\\Users\\sony\\Desktop\\软件测试顺序.jpg"); driver.findElement(By.linkText("确定")).click(); }
报错如下:
77行对应的是
jsExecutor.executeScript(js);
。不仅如此,我在这段代码的里面加什么都会报错,加链接地址也跳不过去。也报空指针。