Warning: file_get_contents(/data/phpspider/zhask/data//catemap/9/silverlight/4.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Php 使用Selenium上载文件_Php_Testing_Automation_Automated Tests_Selenium Rc - Fatal编程技术网

Php 使用Selenium上载文件

Php 使用Selenium上载文件,php,testing,automation,automated-tests,selenium-rc,Php,Testing,Automation,Automated Tests,Selenium Rc,如何在自动化测试中使用Selenium工具上传文件?我尝试了以下代码: selenium.attachFile(//*[@id='file-uploader']/div/div[1]", "C:\\Users\\Public\\Pictures\\Sample Pictures\Desert.jpg"); 这就是我得到的错误: Malformed URL C:\\Users\\Public\\Pictures\\Sample Pictures\\Desert.png. 必须采用以下

如何在自动化测试中使用Selenium工具上传文件?我尝试了以下代码:

selenium.attachFile(//*[@id='file-uploader']/div/div[1]",
    "C:\\Users\\Public\\Pictures\\Sample Pictures\Desert.jpg"); 
这就是我得到的错误:

Malformed URL C:\\Users\\Public\\Pictures\\Sample Pictures\\Desert.png.

必须采用以下格式:

file://C:\Users\Public\Pictures\Sample%20Pictures\Desert.jpg
我们正在处理Windows世界,所以斜杠是向后的

试试这个:

selenium.attachFile(//*[@id='file-uploader']/div/div[1]",
"file://C:\\Users\\Public\\Pictures\\Sample Pictures\\Desert.jpg"); 

你有没有试过用“file:///C:/Users/Public....”“没有。。你能告诉我整个网址吗?试试“file:///C:/Users/Public/Pictures/Sample%20Pictures/Desert.jpg“非常感谢。我会尽力让你知道的。这对我来说不管用。。我也犯了同样的错误我不知道你是否必须逃离太空。试两种方法,告诉我哪种方法有效。我会更新我的答案。