у меня тот же exception получилось что у it_ot
a работающий пример выглядит вот так (assert ы пожалуйста поднастройте для вашего случае самостоятельно):
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 System.Collections.ObjectModel;
using OpenQA.Selenium.Support.UI;
using System.Text.RegularExpressions;
namespace Demo
{
public partial class Form1 : Form
{
IWebDriver Browser;
public Form1()
{
InitializeComponent();
}
// переход по ссылкам
private void button1_Click(object sender, EventArgs e)
{
Browser.Navigate().GoToUrl(comboBox1.Text); // переходим на сайт
IWebElement SearchInput = Browser.FindElement( By.Id(comboBox2.Text) ); // элемент для поиска на странице
SearchInput.SendKeys(textBox2.Text + OpenQA.Selenium.Keys.Enter); // текст для ввода в поисковик + нажатие Enter
}
// закрыть браузер
private void button2_Click(object sender, EventArgs e)
{
Browser.Quit(); // закрытие браузера
}
// открытие браузера
private void button4_Click(object sender, EventArgs e)
{
OpenQA.Selenium.Chrome.ChromeOptions co = new OpenQA.Selenium.Chrome.ChromeOptions();
co.BinaryLocation = @"c:\soft\GoogleChromePortable_1.exe";
co.AddArguments(@"user-data-dir=c:\soft\Data\profile\");
Browser = new OpenQA.Selenium.Chrome.ChromeDriver(co);
}
// поиск элемента
private void button10_Click(object sender, EventArgs e)
{
ReadOnlyCollection<IWebElement> Element = Browser.FindElements(By.XPath("//h3//a[contains(text(), 'программа на c#')]"));
for (int i = 0; i < Element.Count; i++)
{
String s = Element[i].Text;
if (s.ToLower().Contains("программа на C#".ToLower()))
{
textBox1.AppendText("Позиция № " + (i + 1).ToString() + " " + s + "\r\n");
Element[i].SendKeys(OpenQA.Selenium.Keys.Control + OpenQA.Selenium.Keys.Shift + OpenQA.Selenium.Keys.Return);
}
}
} // button10_Click - КОНЕЦ
}
}
Прошу прощения, но ни как не могу “побороть” ошибки
**1.**The name ‘Assert’ does not exist in the current context 2. A local or parameter named ‘e’ cannot be declared in this scope because that name is used in an enclosing local scope to define a local or parameter