我有一个使用Selenium.WebDriver v3.4.0的示例UI测试项目.
当我针对本地驱动程序运行测试时,一切正常,但我想使用Selenium Grid 2来完成工作.
一旦我尝试实例化一个新的RemoteWebDriver,我就会得到一个细节很少的异常.
Driver = new RemoteWebDriver(new Uri(GridUrl), Capabilities);
Run Code Online (Sandbox Code Playgroud)
注意:GridUrl是" http:// localhost:4444/wd/hub "
使用StackTrace引发System.InvalidOperationException,如下所示:
at OpenQA.Selenium.Remote.RemoteWebDriver.UnpackAndThrowOnError(Response errorResponse)
at OpenQA.Selenium.Remote.RemoteWebDriver.Execute(String driverCommandToExecute, Dictionary`2 parameters)
at OpenQA.Selenium.Remote.RemoteWebDriver.StartSession(ICapabilities desiredCapabilities)
at OpenQA.Selenium.Remote.RemoteWebDriver..ctor(ICommandExecutor commandExecutor, ICapabilities desiredCapabilities)
at OpenQA.Selenium.Remote.RemoteWebDriver..ctor(Uri remoteAddress, ICapabilities desiredCapabilities)
at xxxx.Ui.Tests.SeleniumTests.TestInitialize() in C:\Users\xxxx\Documents\Visual Studio 2015\Projects\xxxx.Ui.Tests\xxxx.Tests\PersonTests.cs:line 38
Run Code Online (Sandbox Code Playgroud)
我在本地运行的集线器v3.4.0具有以下配置:
{
"port": 4444,
"newSessionWaitTimeout": -1,
"servlets" : [],
"withoutServlets": [],
"custom": {},
"capabilityMatcher":"org.openqa.grid.internal.utils.DefaultCapabilityMatcher",
"throwOnCapabilityNotPresent": true,
"cleanUpCycle": 5000,
"role": "hub",
"debug": false,
"browserTimeout": 0,
"timeout": 1800
}
Run Code Online (Sandbox Code Playgroud)
Hub始于:
java -jar selenium-server-standalone-3.4.0.jar -role hub
这已经确定并且看起来正在运行. …
我试图在我的Windows 8.1商店应用程序(XAML)中遵循MVVM模式.
我想在UI中单击/点击GridViewItem时导航到新视图.我想在没有代码的情况下执行此操作以提升可测试性(使用MVVM Light).
为了允许我的UI绑定到视图模型命令,我一直在查看通过添加引用 - > Windows - >扩展添加的Microsoft行为SDK(XAML).
我点击网格视图项时,我视图中的以下代码会编译但会爆炸.不幸的是它提供了很少的帮助,只是抛出了未处理的win32异常[3476].
有人可以帮助解决这个问题吗?
使用的命名空间是;
xmlns:interactivity="using:Microsoft.Xaml.Interactivity"
xmlns:core="using:Microsoft.Xaml.Interactions.Core"
<GridView x:Name="itemGridView"
AutomationProperties.AutomationId="ItemGridView"
AutomationProperties.Name="Grouped Items"
ItemsSource="{Binding Source={StaticResource GroupedSource}}"
IsSwipeEnabled="True"
IsTapEnabled="True">
<GridView.ItemTemplate>
<DataTemplate>
<Grid Margin="0"
Height="230">
<StackPanel Orientation="Vertical"
HorizontalAlignment="Stretch">
<Image Source="{Binding Image}"
Stretch="UniformToFill"
HorizontalAlignment="Center"
VerticalAlignment="Center"
/>
<StackPanel VerticalAlignment="Bottom"
Height="45"
Margin="0,-45,0,0">
<StackPanel.Background>
<SolidColorBrush Color="Black"
Opacity="0.75"
/>
</StackPanel.Background>
<TextBlock FontSize="16"
Margin="2"
Text="{Binding Name}"
TextWrapping="Wrap"
VerticalAlignment="Bottom"
/>
</StackPanel>
</StackPanel>
<interactivity:Interaction.Behaviors>
<core:EventTriggerBehavior EventName="Tapped">
<core:InvokeCommandAction Command="{Binding DataContext.SummaryCatagorySelectedCommand, ElementName=LayoutRoot}" />
</core:EventTriggerBehavior>
</interactivity:Interaction.Behaviors>
</Grid>
</DataTemplate>
</GridView.ItemTemplate>
Run Code Online (Sandbox Code Playgroud)
编辑.根据要求,我添加了视图模型,特别包含了我想从我的行为中触发的命令.
public class ViewModel : ViewModelBase
{ …Run Code Online (Sandbox Code Playgroud) 我有一个自定义异常FilterAttribute,如下所示:
[AttributeUsage(AttributeTargets.Class | AttributeTargets.Method, AllowMultiple = true)]
public sealed class ExceptionLoggingFilterAttribute : FilterAttribute, IExceptionFilter
{
public void OnException(ExceptionContext filterContext)
{
if (filterContext == null)
{
throw new ArgumentNullException(nameof(filterContext));
}
if (filterContext.ExceptionHandled)
{
return;
}
// some exception logging code (not shown)
filterContext.ExceptionHandled = true;
}
Run Code Online (Sandbox Code Playgroud)
我在FilterConfig.cs中全局注册了这个
public static class FilterConfig
{
public static void RegisterGlobalFilters(GlobalFilterCollection filters)
{
filters?.Add(new ExceptionLoggingFilterAttribute());
}
}
Run Code Online (Sandbox Code Playgroud)
我还在我的global.asax.cs中声明了一个Application_Error方法
protected void Application_Error(object sender, EventArgs e)
{
var exception = Server.GetLastError();
// some exception logging code (not shown) …Run Code Online (Sandbox Code Playgroud) 嗨,我有一个datagrid,它有许多datagridtemplate列,除了它们在模板的stackpanel上都有不同的datacontext之外,它们都是相同的.
<toolkit:DataGridTemplateColumn Header="Col 1">
<toolkit:DataGridTemplateColumn.CellTemplate>
<DataTemplate>
<StackPanel DataContext="{Binding Times[0]}">
<!-- the structure that I want to extract to a template -->
</StackPanel>
</DataTemplate>
</toolkit:DataGridTemplateColumn.CellTemplate>
</toolkit:DataGridTemplateColumn>
<toolkit:DataGridTemplateColumn Header="Col 2">
<toolkit:DataGridTemplateColumn.CellTemplate>
<DataTemplate>
<StackPanel DataContext="{Binding Times[1]}">
<!-- the same structure here -->
</StackPanel>
</DataTemplate>
</toolkit:DataGridTemplateColumn.CellTemplate>
</toolkit:DataGridTemplateColumn>
Run Code Online (Sandbox Code Playgroud)
我想让每一列使用一个特定的itemtemplate(就像我已经完成了一个列表框),但似乎看不出如何,除非我遗漏了一些东西.
我一直试图模拟网络流进行一些单元测试.
到目前为止,使用Moq我得到的最好的是使用流的包装器然后模拟我的界面.
public interface INetworkstreamWrapper
{
int Read(byte[] buffer, int offset,int size);
void Flush();
bool DataAvailable { get; }
bool CanRead { get; }
void close();
}
Run Code Online (Sandbox Code Playgroud)
问题是,虽然这给了我一个开始,但实际上我想测试一些字节数组值作为读入我的读缓冲区.在模拟对象上调用Read()时,如何将一些测试数据返回到缓冲区?
我想从我的上下文中返回一个项目,如下所示
using (var context = new MyContext())
{
var person = context.People.OrderByDescending(x => x.LastUpdatedDate).FirstOrDefault();
}
Run Code Online (Sandbox Code Playgroud)
我的上下文如下:
public DbSet<Person> People { get; set; }
Run Code Online (Sandbox Code Playgroud)
为什么上面我的person变量的类型不是Person动态代理类型,如System.Data.Entity.DynamicProxies
.Person_5E43C6C196972BF0754973E48C9C941092D86818CD94005E9A759B70BF6E48E6?
如果我使用Find,那么我确实得到类型Person.我想按照上次更新日期的顺序返回前1条记录,OrderByDescending/ FirstOrDefault似乎是最合乎逻辑的方法.
我意识到我可以关闭动态代理生成,但我不认为这是必要的.
假设我的问题是哪个linq方法导致对象被返回为您可能期望的类型并返回动态代理类型?
我们有一个 mongoDB 副本集,它有 3 个节点;
不知何故,我们的副本集最终将 1 和 2 都设置为次要成员。我不确定这是怎么发生的(我们有一个服务器迁移,其中一个节点运行,但只有一个)。
无论如何,我一直在尝试按照此处的指南为副本集重新选举一个新的主节点
我无法使用
rs.reconfig(cfg)
Run Code Online (Sandbox Code Playgroud)
因为它只有在针对主要(我没有)时才有效。
使用 force 参数
rs.reconfig(cfg, { force: true})
Run Code Online (Sandbox Code Playgroud)
似乎可以工作,但是当我重新查询副本集的状态时,两台服务器仍仅显示为辅助服务器。
为什么强制重新配置不起作用?目前,无论我尝试什么,数据库都被锁定。
我有一个标签式应用程序,我希望用户能够搜索一个人,然后在新视图中显示该人的详细信息.用户应该能够为不同的人打开多个人员详细信息视图.
我有点不确定我是否遵循了创建新视图的正确程序.使用Unity(我不是)它似乎你会调用Container.Resolve(view)但是我正在执行以下操作,satisfImports是必要的,以便在视图/ viewmodel中创建我的导入.
PersonDetailView view = new PersonDetailView();
_container.SatisfyImportsOnce(view);
_regionManager.Regions["MainRegion"].Add(view, this.SelectedPerson.Name);
_regionManager.RequestNavigate("MainRegion", new Uri("PersonDetailView", UriKind.Relative));
Run Code Online (Sandbox Code Playgroud)
在我的PersonDetailView的代码中,我有以下属性来设置数据上下文.
[Import]
public PersonDetailsViewModel ViewModel
{
set
{
this.DataContext = value;
}
}
Run Code Online (Sandbox Code Playgroud)
这似乎有效,但我遇到的麻烦是,当我创建第二人称视图时,新视图获取与已创建的视图相同的datacontext实例.
这是因为我正在错误地创建我的观点,还是有一种方法可以告诉MEF在满足我的新视图的导入时创建新的对象?