- using System;
- using System.Collections.Generic;
- using System.ComponentModel;
- using System.Data;
- using System.Drawing;
- using System.Linq;
- using System.Text;
- using System.Windows.Forms;
- using OpenQA.Selenium;
- using OpenQA.Selenium.Chrome;
- using OpenQA.Selenium.Firefox;
- namespace Test
- {
- public partial class Form1 : Form
- {
- public Form1()
- {
- InitializeComponent();
- }
- private void button1_Click(object sender, EventArgs e)
- {
- IWebDriver driver = new ChromeDriver();
- driver.Navigate().GoToUrl("http://www.baidu.com");
- // IWebDriver driver = new FirefoxDriver();
-
- }
- }
- }
复制代码 IWebDriver driver = new ChromeDriver();
报
WebDriverException:
Cannot start the driver service on http://localhost:27784/
没有开启selenium-server.jar。
http://cache.baiducontent.com/c? ... 280014ce31&p1=1
{
网上说不用开启啊。。
1. Selenium Server:和Selenium RC一样的,通过指定远端服务器IP地址和端口号,由这个远端服务器来驱动浏览器。
2. 直接调用:无须指定任何服务器IP地址和端口号。直接使用本地的浏览器(只要安装相应的浏览器,如IE、Firefox、Chrome)
不使用Selenium Server: WebDriver driver = new FirefoxDriver(); 使用Selenium Server: DesiredCapabilities capabilities = new DesiredCapabilities("firefox", "", Platform.ANY);
WebDriver driver = new RemoteWebDriver(new URL("http://127.0.0.1:4444/wd/hub/"), capabilities); }
|