小编Kov*_*hta的帖子

如何使用 Javascriptexecutor 在没有 Id 作为定位器的元素中输入文本?

我想在文本框中输入文本,该文本框不通过 SendKeys 接受输入。我继续使用 Javascriptexecutor 输入文本并成功。现在有一些字段没有可以选择作为定位器的 ID,因此我需要使用 Xpath 来定位它们。我想知道如何在 Javascriptexecutor 中通过 xpath 定位元素并将值传递给它。

JavascriptExecutor jse = (JavascriptExecutor)driver
jse.executeScript("document.getElementById('value').value='1611 
Dragons';");
Run Code Online (Sandbox Code Playgroud)

我需要一种可以使用它的方法,例如:

document.getElementByXpath("Xpath Here").value='xyz';");
Run Code Online (Sandbox Code Playgroud)

如果之前在某处记录过,请随时引导我找到文档/答案。

javascript selenium webdriver selenium-chromedriver selenium-webdriver

5
推荐指数
1
解决办法
3万
查看次数

Nightwatch:无法创建新服务:ChromeDriverService

我正在尝试使用验证登录的 Nightwatch 框架自动化一个简单的测试用例。我已按照以下步骤操作:https : //www.softwaretestingmaterial.com/browser-automation-with-nightwatch-and-selenium/

当我在 node.js 命令提示符下执行命令 node nightwatch tests/bing_test.js 时出现问题,这会导致错误消息。

下面是我的 nightwatch.json 配置:

{
    "src_folders": ["tests"],
    "output_folder": "reports",
    "custom_commands_path": "",
    "custom_assertions_path": "",
    "page_objects_path": "",
    "globals_path": "",

    "selenium": {
        "start_process": true,
        "server_path": "./lib/selenium-server-standalone-3.8.1.jar",
        "log_path": "./reports",
        "host": "127.0.0.1",
        "port": 4445,
        "cli_args": {
            "webdriver.chrome.driver": "./lib/drivers/chromedriver.exe",
            "webdriver.gecko.driver": "./lib/drivers/geckodriver.exe",
            "webdriver.edge.driver": "./lib/drivers/MicrosoftWebDriver.exe"
        }
    },

    "test_settings": {
        "default": {
            "launch_url": "http://localhost",
            "selenium_port": 4445,
            "selenium_host": "localhost",
            "silent": true,
            "screenshots": {
                "enabled": true,
                "path": "./reports/screenshots"
            },
            "desiredCapabilities": {
                "browserName": "chrome",
                "marionette": true,
                "javascriptEnabled": true,
                "acceptSslCerts": true …
Run Code Online (Sandbox Code Playgroud)

node.js nightwatch.js

5
推荐指数
0
解决办法
1132
查看次数

如何在 Java 中查找 2019 年 2 月 24 日格式的未来日期(例如从今天起两个月)

以下是我要采用的方法:

Date DateObject = new Date();
SimpleDateFormat formatDate = new SimpleDateFormat("dd MMMM yyyy");
String dateString = formatDate.format(DateObject);
System.out.println(dateString);
Run Code Online (Sandbox Code Playgroud)

现在这给了我所需格式的当前日期。我想找到从该日期算起两个月内相同格式的日期值。

我还尝试使用以下方法:

LocalDate futureDate = LocalDate.now().plusMonths(2);
Run Code Online (Sandbox Code Playgroud)

这为我提供了我想要的日期,即从现在起两个月后的日期,但格式为 2019-04-24。当我尝试使用 SimpleDateFormat 格式化此日期时,它给了我非法参数异常。

java date date-formatting localdate

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