在具有基类的多个浏览器中运行Selenium测试

假设我有代码: namespace SeleniumTests { [TestFixture(typeof(FirefoxDriver))] [TestFixture(typeof(InternetExplorerDriver))] public class TestWithMultipleBrowsers where TWebDriver : IWebDriver, new() { private IWebDriver driver; [SetUp] public void CreateDriver () { this.driver = new TWebDriver(); } [Test] public void GoogleTest() { driver.Navigate().GoToUrl(“http://www.google.com/”); IWebElement query = driver.FindElement(By.Name(“q”)); query.SendKeys(“Bread” + Keys.Enter); Thread.Sleep(2000); Assert.AreEqual(“bread – Google Search”, driver.Title); driver.Quit(); } } } 我想阻止 [SetUp] public […]

更改ContentControl.Content时开始动画

我正在尝试在Button或ContentControl等内容控件更改其内容时触发动画。 我最初的想法是这样做: 但是我不知道更改/更新ContentPresenter时会触发哪个事件。 有任何想法吗?

添加Azure Ad Oauth2 JWT令牌声明

我只是想知道是否有办法通过Azure门户添加或指定Azure Ad OAuth2 JWT令牌的自定义声明? 或者这只是可能的代码方面?

System.DirectoryServices很慢?

当用户登录网站时,我正在使用以下代码在Active Directory中查找信息。 针对本地域运行它非常快,但是通过VPN运行到远程可信域,它非常慢(需要大约7或8秒)。 从同一个盒子到远程域运行dsa.msc几乎和在本地运行它一样快。 我正在使用属性过滤来检索可能的最小数据量,因此在这种情况下System.DirectoryServices是否存在某些内在缓慢的问题,或者是否有人对如何提高性能有任何提示? 通过VPN的网络连接很好,只有这个代码运行缓慢。 using System; using System.Collections.Generic; using System.Linq; using System.Text; using System.DirectoryServices; namespace ConsoleApplication1 { class Program { static void Main(string[] args) { using (var LDAPConnection = new DirectoryEntry(“LDAP://domain/dc=domain,dc=com”, “username”, “password”)) { LDAPConnection.AuthenticationType = AuthenticationTypes.Secure; using (DirectorySearcher Searcher = new DirectorySearcher(LDAPConnection)) { Searcher.Filter = “(&(&(objectclass=user)(objectcategory=person))sAMAccountName=username)”; Searcher.PropertiesToLoad.Add(“mail”); SearchResult result = Searcher.FindOne(); //this […]

在C#中按X或Close()时,WinForms表单不会关闭

我有一些奇怪的问题,WinForm似乎拒绝关闭一些奇怪的原因。 我有一个非常简单的gui,有时我不会对X做出反应,或者当我在按钮上使用事件时它甚至到达Close()并且什么都不做.. private void buttonZapisz_Click(object sender, EventArgs e) { string plik = textBoxDokumentDoZaladowania.Text; if (File.Exists(plik)) { string extension = Path.GetExtension(plik); string nazwaPliku = Path.GetFileName(plik); SqlMethods.databaseFilePut(plik, comboBoxTypDokumentu.Text, textBoxKomentarz.Text, sKlienciID, sPortfelID, extension, nazwaPliku); Close(); } } 没有为FormClosed或FormClosing分配事件。 那我该怎么知道出了什么问题呢。 有时X会在加载GUI之后工作,但是在我按下Button将一些内容保存到数据库后,它会在该按钮事件中到达Close()并且它仍然可见并且什么都不做。 不能使用X,也不能使用ALT + F4。 我可以绕过GUI并为ComboBox选择其他值而不会出现问题。 我像这样调用GUI: private void contextMenuDokumentyDodaj_Click(object sender, EventArgs e) { var lv = (ListView) contextMenuDokumenty.SourceControl; string […]

C#强制ListBox更新元素

我是标准ListBox控件的子类。 我收到有关添加到列表中的任何元素的更改的通知。 任务是更新ListBox显示的文本以更改元素。 我知道我可以删除已更改的元素并再次添加它,但出于明显的原因,这似乎不太可取。

单实例窗口形成应用程序以及如何获取它的参考?

我有一个Windows窗体应用程序,当时只允许一个实例运行。 我已经使用Mutex实现了Singleton。 应用程序必须可以从命令行启动(带或不带参数)。 应用程序由脚本启动和退出。 用户不能对其采取任何行动。 因此,应用程序的目的是简单的“指标”应用程序,它将只为最终用户显示一些视觉和图形信息。 最终用户无法对其进行任何操作,只需查看即可。 它是Windows窗体应用程序,因为视觉和图形外观是相对容易的实现(你可以得到它最顶层,无边框等)。 简单地说:当有人试图用退出命令行参数运行相同的应用程序时,如何退出当前运行的应用程序? bool quit = (args.Length > 0 && args[0] == “quit”) ? true : false; using (Mutex mutex = new Mutex(false, sExeName)) { if (!mutex.WaitOne(0, true)) { if (quit) { // This is the tricky part? // How can I get reference to “previous” launced // Windows […]

示例:使用.NET / C中的委托加速Reflection API#

正如本文中所提到的 ,我想出了一个使用Delegate加速.NET / C#中的Refection的示例。 但是,运行时出现此错误(编译工作正常)。 可能有什么问题? Unhandled Exception: System.ArgumentException: type is not a subclass of Multicastdelegate at System.Delegate.CreateDelegate (System.Type type, System.Object firstArgument, System.Reflection.MethodInfo method, Boolean throwOnBindFailure, Boolean allowClosed) [0x00000] in :0 at System.Delegate.CreateDelegate (System.Type type, System.Reflection.MethodInfo method, Boolean throwOnBindFailure) [0x00000] in :0 at System.Delegate.CreateDelegate (System.Type type, System.Reflection.MethodInfo method) [0x00000] in :0 at EX.RefTest.DelegateTest () [0x00000] […]

其中一个主键值的类型与实体中定义的类型不匹配。 请参阅内部exception了解详细信

我有以下方法: – public ActionResult CustomersDetails(string[] SelectRight) { var selectedCustomers = new SelectedCustomers { Info = SelectRight.Select(GetAccount) }; return View(selectedCustomers); } private AccountDefinition GetAccount(string id) { return entities.AccountDefinition.Find(id); } 但它返回以下错误: – The type of one of the primary key values did not match the type defined in the entity. See inner exception for details. 在return entities.AccountDefinition.Find(id); […]

创建一个显示更新通知的NuGet包

我正在创建一个NuGet包,我希望每当包的更新存在于存储库(这是一个私有存储库,而不是官方的NuGet存储库)时,包都会显示通知。 请注意,我不希望程序包自动更新(如果新版本可能会引入一些问题),而只是通知用户。 为此,我在包中的init.ps1文件中添加了这个: param($installPath, $toolsPath, $package, $project) $PackageName = “MyPackage” $update = Get-Package -Updates | Where-Object { $_.Id -eq $PackageName } if ($update -ne $null -and $update.Version -gt $package.Version) { [System.Windows.Forms.MessageBox]::Show(“New version $($update.Version) available for $($PackageName)”) | Out-Null } 需要检查$update.Version -gt $package.Version以避免在安装较新的软件包时显示通知。 我想知道是否 这个解决方案是可以接受的,或者如果有更好的“标准”方法(而不是酿造我自己的解决方案)。 有一种更好的方式来显示通知,因为MessageBox相当烦人:当我打开项目时,它隐藏在“准备解决方案”对话框后面,直到我点击确定才完成操作。