简体   繁体   English

在Visual Studio中使用C#和ChromeDriver进行MS Test的Selenium WebDriver

[英]Selenium WebDriver with MS Test using C# and ChromeDriver in Visual Studio

I'm trying to get a few demo test to run using chrome, but i got the following error: 我正在尝试使用chrome运行一些演示测试,但是出现以下错误:

An exception of type 'OpenQA.Selenium.WebDriverException' occurred in WebDriver.dll but was not handled in user code

Additional information: The HTTP request to the remote WebDriver server for URL http://localhost:57523/session timed out after 60 seconds.

I already added the chromedriver to the solution, first I hardcoded the path when declaring the driver, but then I found this post: Selenium WebDriver.ChromeDriver Nuget package installed, but not working for MSTest and followed some of the steps (from 2 to 4). 我已经在解决方案中添加了chromedriver,首先在声明驱动程序时对路径进行了硬编码,但随后发现了以下信息: Selenium WebDriver.ChromeDriver Nuget软件包已安装,但不适用于MSTest,并遵循了一些步骤(从2到4) )。

This is the code i'm using: 这是我正在使用的代码:

using System;
using Microsoft.VisualStudio.TestTools.UnitTesting;
using OpenQA.Selenium;
using OpenQA.Selenium.Firefox;
using OpenQA.Selenium.Chrome;
using OpenQA.Selenium.Support.UI;

namespace TestDemo1
{
    [TestClass]
    public class UnitTest1
    {
        static IWebDriver driver;

        [AssemblyInitialize]
        public static void SetUp(TestContext context)
        {
            //driver = new FirefoxDriver();
            driver = new ChromeDriver();
        }
        [TestMethod]
        public void TestMethod1()
        {
            driver.Navigate().GoToUrl("http://www.hazmeelchingadofavor.com");
        }

        [TestMethod]
        public void TestMethod2()
        {            
            driver.Navigate().GoToUrl("http://www.google.com");
            driver.FindElement(By.Id("gbqfq")).SendKeys("Selenium");
            driver.FindElement(By.Id("gbqfq")).SendKeys(Keys.Enter);
        }

        [AssemblyCleanup]
        public static void TearDown()
        {
            driver.Quit();
        }
    }
}

I'm using VS Express 2013 for Web, in case you were wondering, also when I use the firefox driver, everything works perfectly 我正在使用VS Express 2013 for Web,以防万一,我在使用firefox驱动程序时,一切运行正常

EDIT 10/23/2014: 编辑10/23/2014:

  1. Chrome Version: 38.0.2125.104 m Chrome版本:38.0.2125.104 m
  2. Chrome Driver: 2.11 Chrome驱动程序:2.11
  3. Selenium .Net: 2.43.1 Selenium .Net:2.43.1
  4. Windows: 7 Enterprise 64 bit Windows:7企业版64位

It is a known bug: https://code.google.com/p/chromedriver/issues/detail?id=928 try to update to Chrome Driver: 2.12, this version fix another issue: Resolved issue 916: Selenium (javascript) fails when switching to webview window in Chrome apps [Pri-2] - https://code.google.com/p/chromedriver/issues/detail?id=916 这是一个已知的错误: https : //code.google.com/p/chromedriver/issues/detail?id=928尝试更新到Chrome驱动程序:2.12,此版本修复了另一个问题:已解决的问题916:Selenium(javascript)在Chrome应用[Pri-2]中切换到Webview窗口时失败-https: //code.google.com/p/chromedriver/issues/detail? id =916

may be it solves your problem. 也许可以解决您的问题。 For me downgrading chrome and using old driver solved problem 对我来说,降级chrome并使用旧的驱动程序可以解决问题

Found the solution, we put a bit more attention into the error message and found a message about the sockets (can't recall it really good) so we call the IT department and ask for someone to come over, we talked the issue and the possible solution, so the solution: 找到解决方案后,我们将更多的注意力放在了错误消息上,并找到了有关套接字的消息(记不起来真的很好),因此我们致电IT部门并要求有人过来,我们讨论了该问题,并且可能的解决方案,因此解决方案:

Long Story Short: 长话短说:

The anti-virus was blocking the chromedriver so it couldn't connect, so the IT guy added a rule to allow full execution on chromedriver and that was it, hours and hours of research and the issue was the anti-virus, if you have a similar problem check with your IT department 杀毒软件阻止了chromedriver使其无法连接,因此IT专家添加了一条规则,允许在chromedriver上完全执行,就是这样,研究了数小时之久,问题是杀毒软件(如果有)与您的IT部门进行类似的问题检查

暂无
暂无

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

相关问题 Selenium WebDriver C#Visual Studio N单元测试名称 - Selenium WebDriver C# Visual Studio N Unit Test Name Selenium WebDriver和ChromeDriver-C#Visual Studio2012。无法调试 - Selenium WebDriver with ChromeDriver - C# Visual Studio 2012. Debugging impossible Selenium WebDriver C# 测试脚本中不存在 ChromeDriver - ChromeDriver does not exist in Selenium WebDriver C# test script 使用C#与Selenium WebDriver和NUnit一起调试Visual Studio 2013 - Debug Visual Studio 2013 Using C# with Selenium WebDriver and NUnit Selenium Webdriver带有C#和Visual Studio的dependsOnMethod - Selenium Webdriver dependsOnMethod with C# and Visual Studio Selenium ChromeDriver (C#) 仅在 Visual Studio 调试模式下崩溃 - Selenium ChromeDriver (C#) Crashes Only in Visual Studio Debug Mode 如何使用Visual Studio在C#中创建硒测试 - how to create a test for selenium in C# using visual studio Selenium Webdriver - 如果未在调试模式C#visual studio中运行,则测试失败 - Selenium Webdriver - Test fails assert if not running in Debug Mode C# visual studio Selenium webdriver - 如何连接到由 Visual Studio 使用 C# 打开的同一个 firefox 实例 - Selenium webdriver - How to connect to the same firefox instance open by Visual Studio using C# 如何使用单个 Selenium c# Webdriver/ChromeDriver 在两个选项卡中打开 2 个不同的链接? - How to open 2 different links in two tabs using a singe Selenium c# Webdriver/ChromeDriver?
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM