I need to load my current google chrome profile with all the extensions/cookies/logins & passwords for sites using C# & Selenium chrome driver. Please help me to put correct code lines in the correct places.
I found some info how people did this with python , but even in those threads there are no answers where to put that code.
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 System.Threading;
using OpenQA.Selenium;
using OpenQA.Selenium.Chrome;
namespace WindowsFormsApp2
{
public partial class Form1 : Form
{
IWebDriver Browser;
public Form1()
{
InitializeComponent();
}
private void button1_Click(object sender, EventArgs e)
{
IWebElement element;
Browser = new OpenQA.Selenium.Chrome.ChromeDriver();
Browser.Manage().Window.Maximize();
Browser.Navigate().GoToUrl("https://google.com");
Thread.Sleep(3000);
}
private void button2_Click(object sender, EventArgs e)
{
Browser.Quit();
}
Code I provided successfully opens an empty google chrome profile. I need the selenium chrome driver to open google chrome with my google chrome profile instead of empty profile.
Welcome to SO. You can use the chromeoptions.
ChromeOptions options = new ChromeOptions();
options.addArguments("user-data-dir=/path/to/your/custom/profile");
Refer to the http://chromedriver.chromium.org/capabilities , for more information. Make sure to use the chrome option with driver.
IWebDriver driver = new ChromeDriver(options);
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.