Warning: file_get_contents(/data/phpspider/zhask/data//catemap/8/selenium/4.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
无法使用selenium java上载文件_Selenium_Selenium Webdriver_File Upload - Fatal编程技术网

无法使用selenium java上载文件

无法使用selenium java上载文件,selenium,selenium-webdriver,file-upload,Selenium,Selenium Webdriver,File Upload,我试图在这个网站上传一张照片,但出现了例外。这是我的密码 public static void main(String[] args) throws InterruptedException { System.setProperty("webdriver.chrome.driver", "I:\\Selenium\\chromedriver.exe"); WebDriver driver= new ChromeDriver(); JavascriptExecutor

我试图在这个网站上传一张照片,但出现了例外。这是我的密码

public static void main(String[] args) throws InterruptedException {


    System.setProperty("webdriver.chrome.driver", "I:\\Selenium\\chromedriver.exe");
    WebDriver driver= new ChromeDriver();
     JavascriptExecutor js = (JavascriptExecutor) driver;
    driver.get("https://jpg2png.com");
    driver.manage().window().maximize();
    js.executeScript("window.scroll(0,100)");


    WebElement Pic=driver.findElement(By.id("pick-files"));
    String js1 = "arguments[0].style.height='auto'; arguments[0].style.visibility='visible';";

    Pic.sendKeys("D:\\University Work\\6th Semester\\IAP\\outline.jpg");

    Thread.sleep(10000);
    driver.quit();
}
}

浏览器打开的网站也会打开,但无法上传。type=“file”在html代码中也不存在。 例外情况是:
线程“main”org.openqa.selenium.elementnotinteractitableexception:元素不可交互

尝试单击上载按钮。现在,您输入要上载的文件的路径,但不单击上载按钮

写入“但出现异常”。。将异常添加到描述stacktrace将极大地帮助解决该问题。线程“main”org.openqa.selenium.elementNotInteractivatableException中的异常:元素不可交互上传表单的HTML标记。为了调试,在“driver.findElement(By.id(“pick files”)”之前执行thread.sleep(5000)解决问题?(如果是,请不要在测试中使用Thread.sleep,而是使用Selenium提供的FluentWait等待元素可用。)