你能上传文件 [英] Are you able to upload a file

查看:111
本文介绍了你能上传文件的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

在这里输入的形象描述

我有一个测试,我想上传图片到使用默认的操作系统上传模式网站。我点击上传后,我无法访问上传画面。有没有办法解决它?我在网上看到,它看起来像有,但我不知道如何实现他们在说什么。

 元素(By.xpath(// DIV [@ ID ='ngdialog28'] / DIV [2] / DIV / DIV [6] / DIV / SPAN))。点击()
元素(By.css(输入[类型= \\文件\\]))点击()。
元素(By.css(输入[类型= \\文件\\]))清()。
元素(By.css(输入[类型= \\文件\\]))的SendKeys(C:\\\\ \\\\ ProgramData国际MeetingMatrix \\\\ MeetingMatrix \\\\ 2010 \\\\ MMIDEMO设置\\\\ Test.mms)。 ;


解决方案

下面的答案从previous文章中,我忽略了进来。
这里是code:

\r
\r

VAR路径=要求('路径');\r
\r
VAR fileToUpload ='把路径在这里',\r
  absolutePath = path.resolve(__目录名,fileToUpload);\r
\r
$(输入[类型=文件]')的SendKeys(absolutePath);

\r

\r
\r

I have a test that I would like to upload pictures to a website that uses the defaulted OS upload modal. After I click upload I cannot access the upload screen. Is there a way around it? I saw online that it looked like there was but I had no idea how to implement what they were saying.

element(By.xpath("//div[@id='ngdialog28']/div[2]/div/div[6]/div/span")).click()
element(By.css("input[type=\"file\"]")).click();
element(By.css("input[type=\"file\"]")).clear();
element(By.css("input[type=\"file\"]")).sendKeys("C:\\ProgramData\\MeetingMatrix International\\MeetingMatrix 2010\\MMIDEMO\\Setups\\Test.mms");

解决方案

The answer below came from a previous post I had overlooked. Here is the code:

var path = require('path');

var fileToUpload = 'Put the path here',
  absolutePath = path.resolve(__dirname, fileToUpload);

$('input[type="file"]').sendKeys(absolutePath);

这篇关于你能上传文件的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆