这里是我想在单击按钮(createRoom_btn)之前检查输入nick_name和room_name的值的代码。但是我没有得到如何使用量角器检查单个if语句中的多个条件。
var nick_name = element(by.model('user.vcard.nickname'));
var room_name = element(by.model('roomName'));
var createRoom_btn = element(by.tagName('button'));
describe('Protractor Demo App', function () {
it('should click on create room button', function () {
condition = function () {
return [
nick_name.getAttribute('value').then(function (value) {
return value.length > 0
}),
room_name.getAttribute('value').then(function (value) {
return value.length > 0
})
];
};
browser.wait(condition, 8000, "Text is still not present").then(function (resp) {
});
//button click
browser.actions().mouseMove(createRoom_btn).click();
});
});
答案 0 :(得分:2)
您应该使用public sealed partial class WebViewLocalImage : Page
{
public WebViewLocalImage()
{
this.InitializeComponent();
Loaded += MainPage_Loaded;
}
private void MainPage_Loaded(object sender, RoutedEventArgs e)
{
var uri = this.myWebView.BuildLocalStreamUri("InternalAssets", "example.html");
this.myWebView.NavigateToLocalStreamUri(uri, new StreamUriResolver());
}
}
public sealed class StreamUriResolver : IUriToStreamResolver
{
public IAsyncOperation<IInputStream> UriToStreamAsync(Uri uri)
{
string path = uri.AbsolutePath;
return GetContent(path).AsAsyncOperation();
}
private async Task<IInputStream> GetContent(string URIPath)
{
try
{
Uri localUri = new Uri("ms-appx:///Assets/" + URIPath);
StorageFile f = await StorageFile.GetFileFromApplicationUriAsync(localUri);
IRandomAccessStream stream = await f.OpenAsync(FileAccessMode.Read);
return stream.GetInputStreamAt(0);
}
catch (Exception)
{
System.Diagnostics.Debug.WriteLine("Invalid URI");
}
return null;
}
}
- http://www.protractortest.org/#/api?view=ProtractorExpectedConditions.prototype.and - 来组合条件。如果您有值等待的值,请使用'and' ExpectedCondition
- http://www.protractortest.org/#/api?view=ProtractorExpectedConditions.prototype.textToBePresentInElementValue。
否则,要检查是否输入了值,您可以编写自定义条件来检查长度。
textToBePresentInElementValue ExpectedCondition
为房间名称创建类似的内容 - var valuePresentNick = function() {
return nick_name.getAttribute('value').then(function(txt) {
return txt.length > 0;
});
};
valuePresentRoom
http://www.protractortest.org/#/api?view=ProtractorExpectedConditions