<bdo id='P5bRm'></bdo><ul id='P5bRm'></ul>

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

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

        Selenium:如何通过 executeScript() 发送可变字符串

        时间:2023-05-28
          <bdo id='nLZEh'></bdo><ul id='nLZEh'></ul>

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

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

                1. 本文介绍了Selenium:如何通过 executeScript() 发送可变字符串的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着跟版网的小编来一起学习吧!

                  问题描述

                  我需要在系统中进行一些自动测试.有些字段得到了验证,它可能不能仅仅通过 sendKeys 来完成(然后我正在这样做,它只是写了一个字符串,而不是整个字符串.尝试通过字符串迭代 sendKeys,没有也可以工作)

                  I need to do some automatic tests within system. Some fields got validations, and it probably can't be done by just sendKeys (then I'm doing it, it just write some one string, not whole. Tried iterating sendKeys thru string, didn't work either)

                  现在我正在尝试通过 javascript 向字段输入值.有类似的东西:

                  Right now I'm trying to input value to field by javascript. Got something like it:

                  WebElement pesel = driver.findElement(fldPesel);
                  jse.executeScript("arguments[0].value='80120804076';", pesel);
                  

                  但是,我不希望在 executeScript 中具有值,而是在 java 变量中具有值,因此它看起来和工作得更好.并得到了一些随机化

                  But, I would want not to have value in executeScript, but java variable, so it would look and work better. And got some randomisation

                  我怎么能这样做?

                  推荐答案

                  根据你的说法我不希望在 executeScript 中有值,但是 java 变量你可以引用 Sting 通过 Java 变量获取值:

                  As per your statement I would want not to have value in executeScript, but java variable you can reference the Sting value through a Java variable :

                  String myValue = "80120804076";
                  WebElement pesel = driver.findElement(fldPesel);
                  jse.executeScript("arguments[0].value='" + myValue + "';", pesel);
                  

                  这篇关于Selenium:如何通过 executeScript() 发送可变字符串的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持跟版网!

                  上一篇:为什么我的测试抛出异常 - 无法在 webdriver 中定位元素? 下一篇:Selenium 在并行运行测试时处理 ProtocolHandshake 错误

                  相关文章

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

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

                    <tfoot id='V86HN'></tfoot>