我测试了在我的应用程序中上传文件(下面的代码)并在本地测试它完美无缺。但是,当我使用BrowserStack测试它时,BrowserStack无法访问本地计算机中的文件。
我已经检查了他们关于将BrowserStack与Node.js一起使用的文档,但我还没有看到任何关于上传功能的文档。我的问题是,如何告诉BrowserStack访问我的本地文件?
之前有没有人遇到过同样的问题?
this.selectJmxFile = function(jmxFilePath, done){
this.driver.findElement(webdriver.By.xpath("//input[@type='file']")).sendKeys(jmxFilePath);
this.driver.wait(function () {
return driver.isElementPresent(webdriver.By.css('.test.files.msg.right'));
}, this.timeout).then(function () {
driver.findElement(webdriver.By.css('.test.files.msg.right')).getText().then(function(text) {
expect(text).to.equal('1 new file(s) selected');
done();
});
});
};
其中jmxFilePath设置为:
this.jmxFile = process.cwd() + '/test/functional/features/data/test.jmx';
谢谢!
答案 0 :(得分:2)
好的,因为事实证明这还没有得到支持,因为这只是在Node.js的selenium v2.45.0中添加的。 BrowserStack一旦支持最新版本的selenium,就会拥有此功能。我猜我必须找到另一种解决方法!
答案 1 :(得分:0)
您需要设置文件检测器,然后将其传输到正在运行测试的远程浏览器堆栈计算机 -
webDriver.setFileDetector(new LocalFileDetector());