- [DEVEXPRESS] Hỗ trợ tìm kiếm highlight không dấu và không khoảng cách trên Gridview Filter
- [C#] Chia sẻ source code phần mềm Image Downloader tải hàng loạt hình ảnh từ danh sách link url
- [C#] Chụp hình và quay video từ camera trên winform
- [C#] Chia sẽ full source code tách file Pdf thành nhiều file với các tùy chọn
- Giới thiệu về Stock Tracker Widget - Công cụ theo dõi cổ phiếu và cảnh báo giá tăng giảm bằng C# và WPF
- [VB.NET] Chia sẻ công cụ nhập số tiền tự động định dạng tiền tệ Việt Nam
- [VB.NET] Hướng dẫn fill dữ liệu từ winform vào Microsoft word
- [VB.NET] Hướng dẫn chọn nhiều dòng trên Datagridview
- Hướng Dẫn Đăng Nhập Nhiều Tài Khoản Zalo Trên Máy Tính Cực Kỳ Đơn Giản
- [C#] Chia sẻ source code phần mềm đếm số trang tập tin file PDF
- [C#] Cách Sử Dụng DeviceId trong C# Để Tạo Khóa Cho Ứng Dụng
- [SQLSERVER] Loại bỏ Restricted User trên database MSSQL
- [C#] Hướng dẫn tạo mã QRcode Style trên winform
- [C#] Hướng dẫn sử dụng temp mail service api trên winform
- [C#] Hướng dẫn tạo mã thanh toán VietQR Pay không sử dụng API trên winform
- [C#] Hướng Dẫn Tạo Windows Service Đơn Giản Bằng Topshelf
- [C#] Chia sẻ source code đọc dữ liệu từ Google Sheet trên winform
- [C#] Chia sẻ source code tạo mã QR MOMO đa năng Winform
- [C#] Chia sẻ source code phần mềm lên lịch tự động chạy ứng dụng Scheduler Task Winform
- [C#] Hướng dẫn download file từ Minio Server Winform
[C#] Selemium Tự động đăng nhập gmail bằng Chrome Driver
Hi! Chào các bạn, bài viết hôm nay, mình sẽ tiếp tục hướng dẫn các bạn sử dụng Selenium để tự động đăng nhập vào Gmail bằng lập trình C#.
Vậy Selenium là gì?
Selenium là một trong những công cụ kiểm thử phần mềm tự động mã nguồn mở (open source test automation tool) mạnh mẽ nhất hiện nay cho việc kiểm thử ứng dụng Web. Selenium script có thể chạy được trên hầu hết các trình duyệt như IE, Mozilla FireFox, Chrome, Safari, Opera; và hầu hết các hệ điều hành như Windows, Mac, Linux.

Source code C#:
try
{
    //get row handle
    var driverService = ChromeDriverService.CreateDefaultService();
    driverService.HideCommandPromptWindow = true;
    ChromeOptions options = new ChromeOptions();
    options.AddArguments("--incognito");
    options.AddArgument(@"--start-maximized");
    var driver = new ChromeDriver(driverService, options);
    driver.Navigate().GoToUrl("https://accounts.google.com/signin/v2/identifier?uilel=3&hl=en&passive=true&service=youtube&continue=https%3A%2F%2Fwww.youtube.com%2Fsignin%3Fhl%3Den%26next%3D%252F%26action_handle_signin%3Dtrue%26app%3Ddesktop&flowName=GlifWebSignIn&flowEntry=ServiceLogin");
    //driver.Manage().Window.Minimize();
    IWebElement query = driver.FindElement(By.CssSelector("input[type='email']"));
    query.SendKeys(email);
    query = driver.FindElement(By.CssSelector("div#identifierNext"));
    query.Click();
    driver.Manage().Timeouts().ImplicitWait = TimeSpan.FromSeconds(5);
    query = driver.FindElement(By.CssSelector("input[name='password']"));
    query.SendKeys(password);
    driver.Manage().Timeouts().ImplicitWait = TimeSpan.FromSeconds(10);
    Thread.Sleep(500);
    query = driver.FindElement(By.XPath(".//*[@id='passwordNext']//content//span"));
    query.Click();
    Thread.Sleep(1000);
    try
    {
        string a = driver.FindElement(By.CssSelector("h1#headingText")).Text;
        if (a.Contains("Verify it's you"))
        {
            MessageBox.Show("Verify it's you");
            Thread.Sleep(int.Parse(txt_verify.Text) * 1000);
        }
    }
    catch (Exception)
    {
    }
    Thread.Sleep(6000);
    driver.Navigate().GoToUrl(video);
    //driver.Manage().Window.Maximize();        subscribe-button     
    Thread.Sleep(500);
    //driver.Manage().Window.Maximize();
    // ((IJavaScriptExecutor)driver).ExecuteScript("arguments[0].scrollIntoView(true);", query);
    ((IJavaScriptExecutor)driver).ExecuteScript("window.scrollBy(0, 150)");
    //Thread.Sleep(100);
    //query = driver.FindElement(By.XPath("//*[@id=button]"));
    //query.Click();
    //Thread.Sleep(1000); Verify it's you
    //query = driver.FindElement(By.Id("placeholder-area"));
    //query.Click();
    Thread.Sleep(timer * 1000);
    driver.Quit();
    int row = findIndexByValue(email);
    SetRowColorGridView(row);
}
catch (Exception)
{
}
HAVE FUN :)

![[C#] Selemium Tự động đăng nhập gmail bằng Chrome Driver](https://laptrinhvb.net/uploads/users/9a8cb514e4428e85fb4ca07588e9103f.png)

![[C#] Hướng dẫn sử dụng PuppeteerSharp Headless Chrome .NET API](https://laptrinhvb.net/uploads/source/vbnet/PuppeteerSharp_thumb.jpg)

![[C#] Hướng dẫn xuất dữ liệu ra CSV hoặc Excel từ câu lệnh truy vấn T-SQL](https://laptrinhvb.net/uploads/source/image_baiviet/a1eadf68d1d876454d4f1a540ba2dfd6.png)
![[C#] Lưu thông tin cấu hình ứng dụng trong lập trình C#](https://laptrinhvb.net/uploads/source/image_baiviet/fef4659faf09049873984f2d7f12df9c.png)
![[C#] Tìm giá trị trùng lắp và tô màu trên datagridview winform](https://laptrinhvb.net/uploads/source/devexpress/find_duplicate.png)
![[C#] Giới thiệu thư viện Pinvoke.NET demo ứng dụng Copy File with progress bar](https://laptrinhvb.net/uploads/source/csharp/pinvoke_thumb.jpg)
![[C#] Memory Cache là gì, và sử dụng trong ứng dụng Winform](https://laptrinhvb.net/uploads/source/new_image_baiviet/memory_cache.png)
![[C#] Hướng dẫn Export Data to Excel Template sử dụng thư viện Mini Excel](https://laptrinhvb.net/uploads/source/new_image_baiviet/excel_template.png)
![[C#] Mã hóa RSA trong lập trình Csharp](https://laptrinhvb.net/uploads/source/image_baiviet/238085a2539d03d9154494ec1faab2ae.jpg)
![[C#] Hướng dẫn Supend and Resume Process ID in Winform](https://laptrinhvb.net/uploads/source/new_image_baiviet/supend_resume.jpg)
![[C#] Đọc dữ liệu file data từ Spead Sheet Google Api v4](https://laptrinhvb.net/uploads/source/csharp/read_google_speadsheet_csharp_thumb.jpg)
![[C#] Hướng dẫn tạo màn hình chờ Splash Screen Like Microsoft Office](https://laptrinhvb.net/uploads/source/csharp/splash_screen_loading.gif)
![[C#] Hướng dẫn Overlay Icon dưới Taskbar của ứng dụng - lap trinh csharp](https://laptrinhvb.net/uploads/source/image_baiviet/0ed99f089b242555e56f6b8ae748c1bb.gif)
![[C#] Custom Combobox trên winform](https://laptrinhvb.net/uploads/source/new_image_baiviet/custom_flat_combobox_winform.png)
![[C#] Hướng dẫn chuyển đổi DataTable sang Table HTML](https://laptrinhvb.net/uploads/source/csharp/table_html_thumb.png)
![[C#] Hướng Dẫn Tạo Windows Service Đơn Giản Bằng Topshelf](https://laptrinhvb.net/uploads/source/new_image_baiviet/topsheft_windowsservices.png)
![[C#] Sử dụng Value Tuple trong Csharp 7](https://laptrinhvb.net/uploads/source/vbnet/Value-tuple-C-7.png)
![[C#] Hướng dẫn viết ứng dụng duy nhất một thể hiện Single Instance](https://laptrinhvb.net/uploads/source/image_baiviet/ee5c5694be7374629f2c3519e6b061b2.jpg)
![[C#] Hướng dẫn sử dụng iProgress để sử dụng progress bar trong lập trình csharp](https://laptrinhvb.net/uploads/source/csharp/progress_bar_csharp_thumb.jpg)
![[C#] Bắt sự kiện bàn phím chuột bên ngoài ứng dụng winform sử dụng thư viện MouseKeyHook](https://laptrinhvb.net/uploads/source/vbnet/mouse-keyboard-hook-logo.png)
![[C#] Tải thư viện Dll từ Web server vào ứng dụng Winform](https://laptrinhvb.net/uploads/source/new_image_baiviet/dynamic_dll_csharp.png)
![[C#] Lưu trạng thái các control trên Winform vào Registry Windows](https://laptrinhvb.net/uploads/source/vbnet/save_setting_registry_thumb.png)
![[C#] Hướng dẫn sử dụng thư viện Quartz lập lịch công việc hàng ngày](https://laptrinhvb.net/uploads/source/image_baiviet/3036de5d746ae1b36cdd04acca07f3d2.png)
![[C#] Hướng dẫn tạo ứng dụng Chat với GPT sử dụng Open AI API](https://laptrinhvb.net/uploads/source/new_image_baiviet/chat_open_ai_gpt-3.jpg)
![[C#] Hiển thị file trong Folder Window Explorer và Selected File](https://laptrinhvb.net/uploads/source/csharp/selected_file_csharp_thumb.jpg)
