相关疑难解决方法(0)

如何使用Selenium WebDriver处理Windows文件上传?

我在Stackoverflow上使用Selenium WebDriver看到了很多关于文件上传的问题和解决方案.但是没有一个适用于以下场景.

有人给出了如下解决方案

// assuming driver is a healthy WebDriver instance
WebElement fileInput = driver.findElement(By.name("uploadfile"));
fileInput.sendKeys("C:/path/to/file.jpg");
Run Code Online (Sandbox Code Playgroud)

但我还是找不到窗口句柄我该如何处理?

截图

我正在寻找上述方案的解决方案

请检查以下任何网站

http://www.uploadify.com/demos/
http://www.zamzar.com/
Run Code Online (Sandbox Code Playgroud)

java selenium file-upload webdriver selenium-webdriver

41
推荐指数
3
解决办法
13万
查看次数

如何在没有文本框的Selenium中上传文件

我一直在寻找在Selenium 2中上传文件的解决方案.

问题是我尝试上传的网页元素有两种使用方式:拖放或点击按钮.没有字段输入框.并不是说我没有尝试使用sendKeys.我已经在按钮和所有周围元素上尝试过了.

这个问题的第二部分是我在Windows机器上编写,但自动化发生在Linux机器上.这意味着AutoIt不起作用.这是上传框的HTML.

<div class="up-target" id="up-drop-zone">
    <div class="up-drop-zone-pre hidden">
        <p>Please choose a folder to upload</p>
    </div>
    <div class="up-drop-zone-decor">
        <p>Drop one or more files here</p>
        <p>or</p>
        <button name="uploadFile" class="upload">Select Files</button>
        <input type="file" id="up-drop-zone-input" name="files[]" multiple="true">
    </div>
</div>
Run Code Online (Sandbox Code Playgroud)

我正在使用Java,并对Selenium之外的其他方法开放(但是,我只选择了maven存储库).

谢谢!

java selenium automated-tests file-upload selenium-webdriver

9
推荐指数
1
解决办法
8736
查看次数

无效的密钥代码@ java

我正在研究一个用java自动输入内容的系统.这是我写它的方式:

public void typeMessage(String message) {
    for (char c : message.toCharArray()) {
        int code = c;
        if (code > 96 && code < 123) 
            code = code - 32;
        if (c == '@') {
            robot.keyPress(VK_SHIFT);
            robot.keyPress(VK_AT);
            robot.keyRelease(VK_SHIFT);
            robot.keyRelease(VK_AT);
        } else {
            type(code);
        }
    }
    type(VK_ENTER);
}
Run Code Online (Sandbox Code Playgroud)

但是我收到了这个错误:

    Exception in thread "Thread-2" java.lang.IllegalArgumentException: Invalid key code
Run Code Online (Sandbox Code Playgroud)

    robot.keyPress(VK_AT);
Run Code Online (Sandbox Code Playgroud)

java keyboard awtrobot

0
推荐指数
1
解决办法
5820
查看次数