<i id='dG0dq'><tr id='dG0dq'><dt id='dG0dq'><q id='dG0dq'><span id='dG0dq'><b id='dG0dq'><form id='dG0dq'><ins id='dG0dq'></ins><ul id='dG0dq'></ul><sub id='dG0dq'></sub></form><legend id='dG0dq'></legend><bdo id='dG0dq'><pre id='dG0dq'><center id='dG0dq'></center></pre></bdo></b><th id='dG0dq'></th></span></q></dt></tr></i><div id='dG0dq'><tfoot id='dG0dq'></tfoot><dl id='dG0dq'><fieldset id='dG0dq'></fieldset></dl></div>
  • <legend id='dG0dq'><style id='dG0dq'><dir id='dG0dq'><q id='dG0dq'></q></dir></style></legend>
      <bdo id='dG0dq'></bdo><ul id='dG0dq'></ul>

        <small id='dG0dq'></small><noframes id='dG0dq'>

        <tfoot id='dG0dq'></tfoot>

        Webdriver:文件上传

        Webdriver: File Upload(Webdriver:文件上传)

          <small id='sRGvz'></small><noframes id='sRGvz'>

                <tbody id='sRGvz'></tbody>
              <i id='sRGvz'><tr id='sRGvz'><dt id='sRGvz'><q id='sRGvz'><span id='sRGvz'><b id='sRGvz'><form id='sRGvz'><ins id='sRGvz'></ins><ul id='sRGvz'></ul><sub id='sRGvz'></sub></form><legend id='sRGvz'></legend><bdo id='sRGvz'><pre id='sRGvz'><center id='sRGvz'></center></pre></bdo></b><th id='sRGvz'></th></span></q></dt></tr></i><div id='sRGvz'><tfoot id='sRGvz'></tfoot><dl id='sRGvz'><fieldset id='sRGvz'></fieldset></dl></div>
              <tfoot id='sRGvz'></tfoot>
                <bdo id='sRGvz'></bdo><ul id='sRGvz'></ul>
                <legend id='sRGvz'><style id='sRGvz'><dir id='sRGvz'><q id='sRGvz'></q></dir></style></legend>

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

                  问题描述

                  有没有办法与 webdriver 中的文件上传框进行交互?放入路径的表单字段是只读的,所以我无法写入.

                  Is there a way to interact with a File Upload box in webdriver? The form field where the path gets put in is read only so I can't write to that.

                  推荐答案

                  您可以使用 JavaScript 设置输入字段的值.考虑到该字段的 id 是 fileName,下面的示例将输入的值设置为文件 C: empfile.txt:

                  You can set the value of your input field using JavaScript. Considering that the id of the field is fileName the following example will set the value of the input to the file C: empfile.txt:

                  String script = "document.getElementById('fileName').value='" + "C:\\temp\\file.txt" + "';";
                  ((IJavaScriptExecutor)driver).ExecuteScript(script);
                  

                  在本例中,driver 是您的 WebDriver 实例.

                  In this example, driver is your WebDriver instance.

                  请注意,对于类似 Windows 的路径,您必须使用四个反斜杠 (),因为您需要将双反斜杠传递给 JavaScript,因此您必须使用两个额外的斜杠对两者进行转义.另一种选择是使用正斜杠(例如 "C:/tmp/file.txt"),这也应该有效.

                  Please note that you have to use four backslashes () for Windows-like paths because you are required to pass double back-slashes to the JavaScript so you have to escape both with two additional slashes. The other option is to use a forward slash (e.g. "C:/tmp/file.txt") and that should also work.

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

                  本站部分内容来源互联网,如果有图片或者内容侵犯了您的权益,请联系我们,我们会在确认后第一时间进行删除!

                  相关文档推荐

                  C# namespace alias - what#39;s the point?(C# 命名空间别名 - 有什么意义?)
                  Using Xpath With Default Namespace in C#(在 C# 中使用具有默认命名空间的 Xpath)
                  IBM.Data.DB2.Core connection problems(IBM.Data.DB2.Core 连接问题)
                  Generating an EDMX from a DB2 Database(从 DB2 数据库生成 EDMX)
                  Datetime field overflow with IBM Data Server Client v9.7fp5(IBM Data Server Client v9.7fp5 的日期时间字段溢出)
                  IBM .NET Data Provider Connection String issue with Library List(库列表的 IBM .NET 数据提供程序连接字符串问题)
                  <legend id='zGOIa'><style id='zGOIa'><dir id='zGOIa'><q id='zGOIa'></q></dir></style></legend>
                  • <bdo id='zGOIa'></bdo><ul id='zGOIa'></ul>

                    • <small id='zGOIa'></small><noframes id='zGOIa'>

                              <tbody id='zGOIa'></tbody>
                            <tfoot id='zGOIa'></tfoot>
                            <i id='zGOIa'><tr id='zGOIa'><dt id='zGOIa'><q id='zGOIa'><span id='zGOIa'><b id='zGOIa'><form id='zGOIa'><ins id='zGOIa'></ins><ul id='zGOIa'></ul><sub id='zGOIa'></sub></form><legend id='zGOIa'></legend><bdo id='zGOIa'><pre id='zGOIa'><center id='zGOIa'></center></pre></bdo></b><th id='zGOIa'></th></span></q></dt></tr></i><div id='zGOIa'><tfoot id='zGOIa'></tfoot><dl id='zGOIa'><fieldset id='zGOIa'></fieldset></dl></div>