Tag: internet explorer

Selenium IE WebDriver:NoSuchElementException

我正在尝试使用Selenium Internet Explorer WebDriver,但是一旦我尝试在加载的页面中找到一个元素,它就会一直抛出exception。 我正在使用在Windows 8.1 x64计算机上运行的Selenium客户端和版本2.44,Internet Explorer 11(我尝试过32位和64位版本)的.NET实现。 这是我正在使用的C#测试代码: IWebDriver driver = new InternetExplorerDriver(); driver.Navigate().GoToUrl(“http://mytesturl.com”); const string name = “Test”; IWebElement nameElement = driver.FindElement(By.Name(“name”)); nameElement.SendKeys(name); //… 这是我正在运行测试的网页: TestSelenium <form action="” method=”post”> Insert name: Submit 一旦到达driver.FindElement(By.Name(“name”))调用,就会引发exception。 在此之前,执行按预期工作(在实例化webdriver时启动IE并正确导航到URL)。 这是我得到的例外: OpenQA.Selenium.NoSuchElementException : Unable to find element with name == name en OpenQA.Selenium.Remote.RemoteWebDriver.UnpackAndThrowOnError(Response errorResponse) en OpenQA.Selenium.Remote.RemoteWebDriver.Execute(String driverCommandToExecute, Dictionary`2 […]

如何以另一个用户la / netonly启动Internet Explorer进程?

我正在尝试从我们的WPF应用程序启动Internet Explorer作为另一个用户,这样当我们的用户访问(内部)网站时,他们通过集成Windows身份validation进行静默身份validation。 我们不希望将iexplore.exe作为其他用户启动,因为在计算机上首次启动进程时会出现奇怪的部署/环境问题,并且它首次尝试设置IE7 / 8。 但是,如果你有一个如何在每台机器上静音每个IE安装程序的解决方案,我很乐意听到它。 回到我想要的问题。 我可以使用runas从命令提示符中获取我想要的IE模拟行为*(感谢https://serverfault.com/questions/70376/runas-domain-account-still-asks-for-password ): c:\> runas /noprofile /netonly /user:MyDomain\MyUser iexplore.exe *注意:由于很多原因,我不能在我们的WPF应用程序中使用runas ,但最终结果是我想要的。 无论如何,我想要运行runas /noprofile /netonly iexplore.exe的C#等效代码。 我在CreateProcessWithLogonW P / Invoke中途。 这就是我所拥有的: uint LOGON_NETCREDENTIALS_ONLY = 2; var lpStartupInfo = new CreateProcessWithLogonW_PInvoke.STARTUPINFO(); CreateProcessWithLogonW_PInvoke.PROCESS_INFORMATION processInformation; CreateProcessWithLogonW_PInvoke.CreateProcessWithLogonW( userName, domain, pw, LOGON_NETCREDENTIALS_ONLY, null, commandLine, 0, null, null, ref lpStartupInfo, out processInformation); 这成功启动了Internet Explorer,但似乎根本没有模仿用户。 我能够通过runas命令模拟用户,所以我98%确定validation失败不是IE /区域/密码/ […]

如何使用C#最小化IE浏览器?

如何使用C#最小化IE浏览器? 我尝试下面提到的代码不起作用: var processes = Process.GetProcessesByName(“*iexplorer.*”); if (processes.Any()) { var handle = processes.First().MainWindowHandle; ShowWindow(handle, SW_SHOWMINIMIZED); } 有没有其他方法可以实现IE浏览器的最小化?

如何设置ActiveX控件名称

我有一个ActiveX控件,并且已经使用测试证书对其进行了签名,但每个工作正常但问题是我的Internet Explorer显示了一条丑陋的消息 该网站希望运行以下附加组件:“控制名称不可用”中的“不可用”,如果您信任该网站和加载项并希望允许其运行,请单击此处…. 为什么控件名称不可用? 我在C#中创建了这个ActiveX控件,并在我的assemblyInfo.cs中添加了ComVisible属性,这里是代码 using System.Reflection; using System.Runtime.CompilerServices; using System.Security.Permissions; using System.Runtime.InteropServices; // // General Information about an assembly is controlled through the following // set of attributes. Change these attribute values to modify the information // associated with an assembly. // [assembly: System.Runtime.InteropServices.ComVisible(true)] [assembly: AssemblyTitle(“My ActiveX Control”)] [assembly: AssemblyDescription(“My ActiveX Control Description”)] [assembly: […]

IE8的InternetExplorer COM对象忽略活动选项卡

这是在.net 3.5 winform上运行的代码的Web单点登录。 只要ie8只有一个标签打开,代码就可以运行ie6或ie8。 问题是,如果用户打开一个新选项卡(选项卡2,3等)并导航到一个网站(组织内部的Web表单),将执行以下代码,但是COM自动化对象将返回HTMLDocument对于第一个选项卡(选项卡1),即使选项卡2是活动选项卡。 我无法在任何地方找到InternetExplorer或HTMLDocument类中的任何IE选项卡引用。 实际上,IE COM自动化文档中的IE标签相关文档很少。 AutoResetEvent ie2_NavigateCompleteAutoReset; /// /// Given the handle of an Internet Explorer instance, this method performs single sign on to /// several known web login forms. /// /// private void WebFormSignOn(int iEFramHandle) { foreach (SHDocVw.InternetExplorer ie2 in new SHDocVw.ShellWindows()) { if (ie2.HWND == iEFramHandle) { while (true) { […]

新窗口句柄在IE中消失,无法切换到新窗口

我在Internet Explorer 10中使用最新版本的Selenium(2.37.0)与C#(使用最新的32位InternetExplorerDriver,2.37.0)登录网页,单击打开新窗口的按钮,然后将焦点更改为新窗口。 最初我在Firefox中使用这个代码,每次都可以使用它: // Get handle for original window string parentHandle = driver.CurrentWindowHandle; // Click on button for new window driver.FindElement(By.Id(“buttonForNewWindow”)).Click(); // Get list of all window handles ReadOnlyCollection allWindowHandles = driver.WindowHandles; // Loop over all handles and switch to new child window foreach (string handle in allWindowHandles) { if (handle != parentHandle) { […]

通过“C#”清除临时Internet文件

我在windows application.i中使用webbrowser控件正在webbrowser控件中查看url内容。 这里url内容值存储在用户机器的临时Internet文件中。 当我点击我的表单中的关闭按钮时,我正在以编程方式删除临时Internet文件。 它工作正常。 但在删除过程中,“消息框出现并说删除临时Internet文件”。 在这里我不想在删除期间显示该对话框。 下面是删除用户机器临时文件的代码。 怎么处理这个.. void DeleteBrowserTempFile() { string args = “”; args = (“InetCpl.cpl,ClearMyTracksByProcess 8”); System.Diagnostics.Process process = null; System.Diagnostics.ProcessStartInfo processStartInfo; processStartInfo = new System.Diagnostics.ProcessStartInfo(); processStartInfo.FileName = Environment.GetFolderPath(Environment.SpecialFolder.System) + “\\Rundll32.exe”; if ((System.Environment.OSVersion.Version.Major >= 6)) { // Windows Vista or higher processStartInfo.Verb = “runas”; } processStartInfo.Arguments = args; processStartInfo.WindowStyle = System.Diagnostics.ProcessWindowStyle.Hidden; […]

新窗口句柄在IE中消失

这是我在此问过的上一个问题的后续跟进。 我之前遇到过使用Selenium 2.37.0在Internet Explorer 10中切换窗口的问题。 我的C#程序将导航到一个页面,单击一个打开链接的按钮,然后尝试导航到新窗口以执行其他任务。 我的程序一直都失败了,我确定这是因为Selenium的窗口句柄。 打开一个新窗口后,窗口句柄的数量( driver.WindowHandles.Count )会按预期从1增加到2,但经过一段时间后,窗口句柄的数量会下降到1。 我创建了一个可以重现此问题的最小样本网页。 只需将以下代码保存到桌面上名为test.aspx的文件中: 这是我的C#代码(Visual Studio 2010中的一个名为TestWindowSwitching的控制台项目),它打开此页面,单击按钮并打印一些输出: using System; using System.Threading; // Needed for Sleep using System.Diagnostics; // Needed for Stopwatch using OpenQA.Selenium; using OpenQA.Selenium.IE; namespace TestWindowSwitching { class Program { static void Main() { IWebDriver driver = new InternetExplorerDriver(); driver.Navigate().GoToUrl(“C:\\Users\\yourNameHere\\Desktop\\test.aspx”); try { driver.SwitchTo().DefaultContent(); } catch { […]

C#如何从IE获取当前URL?

我想从IE(.NET 4)获取当前的URL。 为此,我添加了对Microsoft Interner Controls的引用并添加了代码(来自http://omegacoder.com/?p=63 ) foreach (InternetExplorer ie in new ShellWindowsClass()) { textBox1.Text = ie.LocationURL.ToString(); } 但我得到2个错误: 1] The type ‘SHDocVw.ShellWindowsClass’ has no constructors defined 2] Interop type ‘SHDocVw.ShellWindowsClass’ cannot be embedded. Use the applicable interface instead. 怎么解决?

从IE下载“签名已损坏或无效”

我获得了Certum证书来签署我的C#应用​​程序。 一切似乎都没问题,我可以执行该应用程序,并在其上看到有效的证书。 但是,如果我将其上传到我的网页(使用Visual Studio发布或上传EXE),我无法在Windows7上使用Internet Explorer下载它。 我总是得到这样的信息:“签名已损坏或无效”。 但是一旦它在PC上,它似乎是有效的。 我知道,IE在2013年有一个错误,但应该解决。 在Windows 10上,Smartscreen也阻止了这个exe,我无法下载它。 我支付了这个证书,certificate我的应用程序是安全的,现在我遇到了比以前更多的问题:( 我不知道我是否可以在这里插入我的应用程序的链接。 编辑 :我在Microsoft找到了这个文档: http : //social.technet.microsoft.com/wiki/contents/articles/32288.windows-enforcement-of-authenticode-code-signing-and-timestamping.aspx – 似乎是微软与IE(以及谷歌与Chrome)不再允许下载SHA-1签名的应用程序,因为它不够安全。