Почему при открытии браузера Google Chrome открывается браузер без расширений (selenium)? - C#
Формулировка задачи:
ИМЕЕТСЯ
Google Chrome Portable (портативный), который расположен в папке c:\soft\UD\GoogleChromePortable\1_1\GoogleChromePortable_1.exe На нём установлены расширения:Site Geo IP Locator
; При запуске ПРОЕКТ 1 на C# (с использованием selenium, WebDriver.dll, chromedriver.exe) открывается браузер Google Chrome Portable, в котором установлено только расширение "Chrome Automation Extension", которое я не устанавливал. Сценарий проекта: 1. открыть браузер Google Chrome Portable, который находится по пути c:\soft\UD\GoogleChromePortable\1_1\GoogleChromePortable_1.exe; 2. открыть поисковик (google.com); 3. ввести слово для поиска; 4. осуществить поиск;ВОПРОС.
1. Почему когда запускаем ПРОЕКТ 1 на C#, который по сценарию открывает браузер Google Chrome Portable, в браузере установлено только расширение "Chrome Automation Extension", которое я не устанавливал, а установленного расширения нет? chrome://extensions/ КОДusing System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Windows.Forms;
using OpenQA.Selenium;
//****//
using System.Diagnostics;
//****//
namespace WindowsFormsApplication1
{
public partial class Form1 : Form
{
IWebDriver Browser;
public Form1()
{
InitializeComponent();
}
private void button1_Click(object sender, EventArgs e)
{
OpenQA.Selenium.Chrome.ChromeOptions co = new OpenQA.Selenium.Chrome.ChromeOptions();
//****//
co.BinaryLocation = @"c:\soft\UD\GoogleChromePortable\1_1\GoogleChromePortable_1.exe";
//****//
Browser = new OpenQA.Selenium.Chrome.ChromeDriver(co);
Browser.Manage().Window.Maximize();
Browser.Navigate().GoToUrl("http://google.com");
IWebElement SearchInput = Browser.FindElement(By.Id("lst-ib"));
SearchInput.SendKeys("проект домов" + OpenQA.Selenium.Keys.Enter);
}
private void button2_Click(object sender, EventArgs e)
{
}
}
}ПРИЛОЖЕНИЕ.
1.GoogleChromePortable.rar - https://yadi.sk/d/P5YwafKTuPbCq 2. ПРОЕКТ_exe.rar - https://yadi.sk/d/xKhCLA4LuPevA 3. ПРОЕКТ_ПОЛНЫЙ.rar - https://yadi.sk/d/RUOpjj64uPexYДЛЯ ЗАПУСКА ПРОЕКТА ТРЕБУЕТСЯ ВЫПОЛНИТЬ СЛЕДУЮЩЕЕ:
1. ПРИЛОЖЕНИЕ 1 (GoogleChromePortable.rar) разархивировать и разместить на диске "C" чтобы файлы находились по следующим путям соответственно: 1. Файл GoogleChromePortable_1.exe - находился по пути c:\soft\UD\GoogleChromePortable\1_1\GoogleChromePortable_1.exe т.е. папку "soft" просто разместить на диске c:\Решение задачи: «Почему при открытии браузера Google Chrome открывается браузер без расширений (selenium)?»
textual
Листинг программы
using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Windows.Forms;
using OpenQA.Selenium;
//****//
using System.Diagnostics;
using OpenQA.Selenium.Chrome;
using System.IO;
//****//
namespace WindowsFormsApplication1
{
public partial class Form1 : Form
{
IWebDriver Browser;
public Form1()
{
InitializeComponent();
}
private void button1_Click(object sender, EventArgs e)
{
OpenQA.Selenium.Chrome.ChromeOptions co = new OpenQA.Selenium.Chrome.ChromeOptions();
co.BinaryLocation = @"c:\soft\UD\GoogleChromePortable\1_1\GoogleChromePortable_1.exe";
co.AddExtensions(@"c:\soft\UD\GoogleChromePortable\1_1\Data\profile\SiteGeoIPLocator.crx");
co.AddArguments(@"c:\soft\UD\GoogleChromePortable\1_1\Data\profile\SiteGeoIPLocator.crx");
// co.AddExtension(Path.GetFullPath("c:\soft\UD\GoogleChromePortable\1_1\profil\SiteGeoIPLocator\SiteGeoIPLocator.crx"));
// chrome://extensions/
//****//
Browser = new OpenQA.Selenium.Chrome.ChromeDriver(co);
Browser.Manage().Window.Maximize();
Browser.Navigate().GoToUrl("http://google.com");
IWebElement SearchInput = Browser.FindElement(By.Id("lst-ib"));
SearchInput.SendKeys("проект домов" + OpenQA.Selenium.Keys.Enter);
}
private void button2_Click(object sender, EventArgs e)
{
}
}
}