我正在尝试使用Protractor为Angular的端到端测试从下拉框中选择选项。
这是选择选项的代码片段:
<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: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,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}]
请问有谁能帮我解决这个问题或指点一下我在这里做错了什么。
element(by.model('selectModel')).click(); element(by.css('md-option[value="searchOptionValue"]')).click();
- Luan NguyenmdSelectElement.getAttribute('aria-owns').then( function(val) { let selectMenuContainer = element(by.id(val)); selectMenuContainer.element(by.css('md-option[value="foo"]')).click(); } );
- gbruins