【发布时间】:2018-03-07 21:00:39
【问题描述】:
我正在尝试将以下代码从带有 selenium-webdriver gem 的 Ruby 移植到带有 WebdriverIO 的 Node.js:
@webdriver.navigate.to "https://imgur.com/upload"
element = @webdriver.find_element(:id, 'global-files-button')
element.send_keys("C:\\test\\image.png")
如您所见,代码非常简单:导航到 url,找到输入,设置文件路径,然后按预期工作,选择要上传的文件。
这是我的移植版本:
describe('User can upload', () => {
it('select file', () => {
browser.url("https://imgur.com/upload");
browser.waitForExist('#global-files-button');
$('#global-files-button').keys("C : \\ t e s t \\ i m a g e . p n g".split(" "));
});
});
不幸的是,这个测试没有设置路径,我还没有找到使用 wdio 上传这样的文件的工作示例,文档让我猜不透。任何建议都非常感谢。
我知道 chooseFile 和 uploadFile,但我正在使用云平台来运行我的 wdio 测试,但它们似乎不能可靠地工作。
【问题讨论】:
标签: node.js selenium-webdriver webdriver webdriver-io