Java 无法使用Selenium Webdriver打开文件上载窗口

Java 无法使用Selenium Webdriver打开文件上载窗口,java,selenium,file-upload,selenium-webdriver,Java,Selenium,File Upload,Selenium Webdriver,我是Selenium Webdriver的新手,我想在单击浏览按钮后打开文件上载窗口,但我无法使用Webdriver打开它 这是我的密码: import org.openqa.selenium.By; import org.openqa.selenium.JavascriptExecutor; import org.openqa.selenium.WebDriver; import org.openqa.selenium.WebElement; import org.openqa.seleniu

我是Selenium Webdriver的新手,我想在单击浏览按钮后打开文件上载窗口,但我无法使用Webdriver打开它

这是我的密码:

import org.openqa.selenium.By;
import org.openqa.selenium.JavascriptExecutor;
import org.openqa.selenium.WebDriver;
import org.openqa.selenium.WebElement;
import org.openqa.selenium.firefox.FirefoxDriver;
import org.openqa.selenium.support.ui.ExpectedConditions;
import org.openqa.selenium.support.ui.WebDriverWait;
public class Login_Page {
 static WebDriver driver;
    public static void main(String args[])
    {
        driver = new FirefoxDriver();
        driver.manage().window().maximize();
        WebDriverWait wait = new WebDriverWait(driver, 40);
WebDriverWait wait = new WebDriverWait(driver, 40);
        driver.manage().timeouts().implicitlyWait(30, TimeUnit.SECONDS);
        driver.get("http://www.toolsqa.com/automation-practice-form");

            driver.findElement(By.id("photo")).click();



    }
}
我无法看到任何文件上载窗口

我正在使用Firefox14.0.1和selenium-server-standalone-2.24.1.jar

请告诉我怎么做?
谢谢

问题在于您的firefox版本。在我看来,这个脚本运行得很顺利。一旦我遇到这样的问题,这个脚本将只使浏览按钮处于焦点。你可以做的是在进入焦点后,发送回车键。 在单击事件后添加此代码段

Actions action = new Actions(driver);
action.sendKeys(Keys.ENTER);

问题在于您的firefox版本。在我看来,这个脚本运行得很顺利。一旦我遇到这样的问题,这个脚本将只使浏览按钮处于焦点。你可以做的是在进入焦点后,发送回车键。 在单击事件后添加此代码段

Actions action = new Actions(driver);
action.sendKeys(Keys.ENTER);

问题在于您的firefox版本。在我看来,这个脚本运行得很顺利。一旦我遇到这样的问题,这个脚本将只使浏览按钮处于焦点。你可以做的是在进入焦点后,发送回车键。 在单击事件后添加此代码段

Actions action = new Actions(driver);
action.sendKeys(Keys.ENTER);

问题在于您的firefox版本。在我看来,这个脚本运行得很顺利。一旦我遇到这样的问题,这个脚本将只使浏览按钮处于焦点。你可以做的是在进入焦点后,发送回车键。 在单击事件后添加此代码段

Actions action = new Actions(driver);
action.sendKeys(Keys.ENTER);

我猜你想在点击上传按钮后上传文件。即使您可以单击upload按钮(这将为您带来弹出窗口),也不能使用selenium调用选择文件

因此,为了上传文件,您需要执行以下操作:

WebElement uploadButton = driver.findElement(//your strategy) //to the upload button
uploadButton.sendKeys("your full path to the file")

此外,您还需要为相应的FireFox浏览器使用最新的Selenium版本

我猜你想在点击上传按钮后上传文件。即使您可以单击upload按钮(这将为您带来弹出窗口),也不能使用selenium调用选择文件

因此,为了上传文件,您需要执行以下操作:

WebElement uploadButton = driver.findElement(//your strategy) //to the upload button
uploadButton.sendKeys("your full path to the file")

此外,您还需要为相应的FireFox浏览器使用最新的Selenium版本

我猜你想在点击上传按钮后上传文件。即使您可以单击upload按钮(这将为您带来弹出窗口),也不能使用selenium调用选择文件

因此,为了上传文件,您需要执行以下操作:

WebElement uploadButton = driver.findElement(//your strategy) //to the upload button
uploadButton.sendKeys("your full path to the file")

此外,您还需要为相应的FireFox浏览器使用最新的Selenium版本

我猜你想在点击上传按钮后上传文件。即使您可以单击upload按钮(这将为您带来弹出窗口),也不能使用selenium调用选择文件

因此,为了上传文件,您需要执行以下操作:

WebElement uploadButton = driver.findElement(//your strategy) //to the upload button
uploadButton.sendKeys("your full path to the file")
此外,您还需要为相应的FireFox浏览器使用最新的Selenium版本

使用以下行:

driver.findElement(By.xpath(.//*[@id='photo'])。单击();

使用以下行:

driver.findElement(By.xpath(.//*[@id='photo'])。单击();

使用以下行:

driver.findElement(By.xpath(.//*[@id='photo'])。单击();

使用以下行:



driver.findElement(By.xpath(.//*[@id='photo'])。单击();

您使用的是哪个firefox版本和哪个selenium服务器独立文件?firefox 13.XX和selenium-2.42.2.jars您使用的是哪个firefox版本和哪个selenium服务器独立文件?firefox 13.XX和selenium-2.42.jars您使用的是哪个firefox版本和哪个selenium服务器独立文件?firefox 13.XX和selenium-2.42.2。jars您使用的是哪个firefox版本和哪个selenium server独立文件?firefox 13.XX和selenium-2.42.jar添加一段HTML。添加一段HTML。添加一段HTML。添加一段HTML。单击“上载”按钮后,我没有看到弹出窗口,这就是我要问的,无法打开上载窗口。另外,请删除我不知道哪一个firefox版本哪个selenium版本最好?我点击上传按钮后没有弹出窗口,这就是我要问的,无法打开上传窗口。另外,请让我知道哪一个firefox版本哪个selenium版本最好?点击上传按钮后我没有弹出窗口上,这就是我要问的,无法打开上载窗口。还请告诉我哪个firefox版本的selenium版本最好?单击上载按钮后,我没有看到弹出窗口,这就是我要问的,无法打开上载窗口。还请告诉我哪个firefox版本的selenium版本请注意,你应该适当地格式化你的答案,增加一些细节,避免用简短的内容来回答问题,这样的解释总是好的。请考虑适当地格式化你的答案,增加一些细节,避免用简短的内容来回答问题,最好是有好的前。请回答,考虑适当地格式化你的答案,增加一些细节,避免用简短的内容来回答问题,最好有好的解释答案。请考虑适当地格式化你的答案,增加一些细节,避免用简短的内容来回答问题,这样总是好的。-解释了答案。