<legend id='MrdYw'><style id='MrdYw'><dir id='MrdYw'><q id='MrdYw'></q></dir></style></legend>

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

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

    1. 如何在下拉 protractorjs e2e 测试中选择选项

      How to select option in drop down protractorjs e2e tests(如何在下拉 protractorjs e2e 测试中选择选项)

          <tbody id='Vgjzl'></tbody>

        <legend id='Vgjzl'><style id='Vgjzl'><dir id='Vgjzl'><q id='Vgjzl'></q></dir></style></legend>
        1. <tfoot id='Vgjzl'></tfoot>

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

              <i id='Vgjzl'><tr id='Vgjzl'><dt id='Vgjzl'><q id='Vgjzl'><span id='Vgjzl'><b id='Vgjzl'><form id='Vgjzl'><ins id='Vgjzl'></ins><ul id='Vgjzl'></ul><sub id='Vgjzl'></sub></form><legend id='Vgjzl'></legend><bdo id='Vgjzl'><pre id='Vgjzl'><center id='Vgjzl'></center></pre></bdo></b><th id='Vgjzl'></th></span></q></dt></tr></i><div id='Vgjzl'><tfoot id='Vgjzl'></tfoot><dl id='Vgjzl'><fieldset id='Vgjzl'></fieldset></dl></div>
                <bdo id='Vgjzl'></bdo><ul id='Vgjzl'></ul>
              • 本文介绍了如何在下拉 protractorjs e2e 测试中选择选项的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着跟版网的小编来一起学习吧!

                问题描述

                我正在尝试从下拉列表中选择一个选项,以使用量角器进行角度 e2e 测试.

                I am trying to select an option from a drop down for the angular e2e tests using protractor.

                这里是选择选项的代码片段:

                Here is the code snippet of the select option:

                <select id="locregion" class="create_select ng-pristine ng-invalid ng-invalid-required" required="" ng-disabled="organization.id !== undefined" ng-options="o.id as o.name for o in organizations" ng-model="organization.parent_id">
                    <option value="?" selected="selected"></option>
                    <option value="0">Ranjans Mobile Testing</option>
                    <option value="1">BeaverBox Testing</option>
                    <option value="2">BadgerBox</option>
                    <option value="3">CritterCase</option>
                    <option value="4">BoxLox</option>
                    <option value="5">BooBoBum</option>
                </select>
                

                我试过了:

                ptor.findElement(protractor.By.css('select option:1')).click();
                

                这给了我以下错误:

                指定了无效或非法的字符串构建信息:版本:'2.35.0',修订:'c916b9d',时间:'2013-08-12 15:42:01'系统信息:os.name:'Mac OS X',os.arch:'x86_64',os.version:'10.9',java.version:'1.6.0_65'驱动信息:driver.version:未知

                An invalid or illegal string was specified Build info: version: '2.35.0', revision: 'c916b9d', time: '2013-08-12 15:42:01' System info: os.name: 'Mac OS X', os.arch: 'x86_64', os.version: '10.9', java.version: '1.6.0_65' Driver info: driver.version: unknown

                我也试过了:

                ptor.findElement(protractor.By.xpath('/html/body/div[2]/div/div[4]/div/div/div/div[3]/ng-include/div/div[2]/div/div/organization-form/form/div[2]/select/option[3]')).click();
                

                这给了我以下错误:

                ElementNotVisibleError:元素当前不可见,因此可能无法与之交互命令持续时间或超时:9 毫秒构建信息:版本:'2.35.0',修订:'c916b9d',时间:'2013-08-12 15:42:01'系统信息:os.name:'Mac OS X',os.arch:'x86_64',os.version:'10.9',java.version:'1.6.0_65'会话 ID:bdeb8088-d8ad-0f49-aad9-82201c45c63f驱动信息:org.openqa.selenium.firefox.FirefoxDriver功能 [{platform=MAC,acceptSslCerts=true,javascript Enabled=true,browserName=firefox,rotatable=false,locationContextEnabled=true,version=24.0,cssSelectorsEnabled=true,databaseEnabled=true,handlesAlerts=true,browserConnectionEnabled=true,nativeEvents=false, webStorageEnabled=true, applicationCacheEnabled=false, takeScreenshot=true}]

                ElementNotVisibleError: Element is not currently visible and so may not be interacted with Command duration or timeout: 9 milliseconds Build info: version: '2.35.0', revision: 'c916b9d', time: '2013-08-12 15:42:01' System info: os.name: 'Mac OS X', os.arch: 'x86_64', os.version: '10.9', java.version: '1.6.0_65' Session ID: bdeb8088-d8ad-0f49-aad9-82201c45c63f Driver info: org.openqa.selenium.firefox.FirefoxDriver Capabilities [{platform=MAC, acceptSslCerts=true, javascriptEnabled=true, browserName=firefox, rotatable=false, locationContextEnabled=true, version=24.0, cssSelectorsEnabled=true, databaseEnabled=true, handlesAlerts=true, browserConnectionEnabled=true, nativeEvents=false, webStorageEnabled=true, applicationCacheEnabled=false, takesScreenshot=true}]

                谁能帮我解决这个问题,或者说明我在这里可能做错了什么.

                Can anyone please help me with this problem or throw some light on what i might be doing wrong here.

                推荐答案

                我也遇到了类似的问题,最后写了一个帮助函数来选择下拉值.

                I had a similar problem, and eventually wrote a helper function that selects dropdown values.

                我最终决定我可以通过选项编号进行选择,因此编写了一个方法,该方法接受一个元素和 optionNumber,并选择该 optionNumber.如果 optionNumber 为 null,则不选择任何内容(不选择下拉菜单).

                I eventually decided that I was fine selecting by option number, and therefore wrote a method that takes an element and the optionNumber, and selects that optionNumber. If the optionNumber is null it selects nothing (leaving the dropdown unselected).

                var selectDropdownbyNum = function ( element, optionNum ) {
                  if (optionNum){
                    var options = element.all(by.tagName('option'))   
                      .then(function(options){
                        options[optionNum].click();
                      });
                  }
                };
                

                如果您想了解更多详细信息,我写了一篇博文,其中还包括在下拉列表中验证所选选项的文本:http://technpol.wordpress.com/2013/12/01/protractor-and-dropdowns-validation/

                I wrote a blog post if you want more detail, it also covers verifying the text of the selected option in a dropdown: http://technpol.wordpress.com/2013/12/01/protractor-and-dropdowns-validation/

                这篇关于如何在下拉 protractorjs e2e 测试中选择选项的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持跟版网!

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

                相关文档推荐

                What are valid deviceNames for Chrome emulation testing with Protractor?(使用 Protractor 进行 Chrome 模拟测试的有效设备名称是什么?)
                Protractor Check if Element Does Not Exist(量角器检查元素是否不存在)
                Protractor e2e Tests Login Redirection(Protractor e2e 测试登录重定向)
                Explain about async/ await in Protractor(解释 Protractor 中的 async/await)
                Protractor browser.wait doesn#39;t wait(量角器 browser.wait 不等待)
                How to use Protractor with Angular 2?(如何在 Angular 2 中使用量角器?)
              • <legend id='Ri6BB'><style id='Ri6BB'><dir id='Ri6BB'><q id='Ri6BB'></q></dir></style></legend><tfoot id='Ri6BB'></tfoot>
                  <i id='Ri6BB'><tr id='Ri6BB'><dt id='Ri6BB'><q id='Ri6BB'><span id='Ri6BB'><b id='Ri6BB'><form id='Ri6BB'><ins id='Ri6BB'></ins><ul id='Ri6BB'></ul><sub id='Ri6BB'></sub></form><legend id='Ri6BB'></legend><bdo id='Ri6BB'><pre id='Ri6BB'><center id='Ri6BB'></center></pre></bdo></b><th id='Ri6BB'></th></span></q></dt></tr></i><div id='Ri6BB'><tfoot id='Ri6BB'></tfoot><dl id='Ri6BB'><fieldset id='Ri6BB'></fieldset></dl></div>
                    <bdo id='Ri6BB'></bdo><ul id='Ri6BB'></ul>

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

                            <tbody id='Ri6BB'></tbody>