fysh711426 / UndetectedChromeDriver

GNU General Public License v3.0
166 stars 61 forks source link

how to open chrome profile (already created manualy) multiple #12

Open umari06 opened 2 years ago

umari06 commented 2 years ago

i make code for 2 profiles and first one start and go in url correctly but the seconde one opened and stuck in url

using System;
using OpenQA.Selenium;
using OpenQA.Selenium.Chrome;
using SeleniumUndetectedChromeDriver;

namespace test_csharp_cns
{
    internal class Program
    {

        static void Main(string[] args)
        {
            Console.WriteLine("vendose url-en");
            string ert = Console.ReadLine();
            var driverExecutablePath = $@"C:\SeleniumProfiles\chromedriver.exe";

            var options = new ChromeOptions();
            options.AddArgument("--user-data-dir=C:/Users/toni-/AppData/Local/Google/Chrome/User Data");
            options.AddArguments("--profile-directory=Profile 1");
            options.AddArgument("--no-sandbox");
            options.AddArgument("--disable-gpu");
            options.AddArgument("--disable-dev-shm-usage");
            options.PageLoadStrategy = PageLoadStrategy.None;
            using var driver = UndetectedChromeDriver.Create( options: options, driverExecutablePath: driverExecutablePath);

            driver.Navigate().GoToUrl(ert);

            var driverExecutablePath1 = $@"C:\SeleniumProfiles\chromedriver.exe";
            var options1 = new ChromeOptions();
            options1.AddArgument("--user-data-dir=C:/Users/toni-/AppData/Local/Google/Chrome/User Data");
            options1.AddArguments("--profile-directory=Profile 2");
            options.AddArgument("--no-sandbox");
            options1.AddArgument("--disable-gpu");
            options1.AddArgument("--disable-dev-shm-usage");
            options1.PageLoadStrategy = PageLoadStrategy.None;
            using var driver1 = UndetectedChromeDriver.Create(options: options1,  driverExecutablePath: driverExecutablePath1);
            driver1.Navigate().GoToUrl(ert);//c:

error is here Untitled11

fysh711426 commented 2 years ago

user-data-dir cannot be shared.

And you have to use userDataDir parameter, and driver.GoToUrl() method.

Try it.
#multiple-instance-example

umari06 commented 2 years ago

i can login in tiktok but when i click like buton after few second disliked auto any idea d.findelement(By.id( "id")).click();

fysh711426 commented 2 years ago

I don't understand. But you can refer WebDriverWait, Trigger some event after waiting for disliked to appear.

umari06 commented 2 years ago

i click button Like❤️ after few second disliked auto maybe from tiktok do u have any code

umari06 commented 2 years ago

if u have time add me on discord AgimBaba#3200

fysh711426 commented 2 years ago

Sorry this question is far away from this repo, I can't help you more.

umari06 commented 2 years ago

i open undetected chrome then i login in tiktok i click Like button of random video direct with mouse after 10 sec disliked auto 1 o

2

fysh711426 commented 2 years ago

The first step, you can try to let selenium to click the like button.

umari06 commented 2 years ago

Tiktok is detecting that chrome is bot cuz i try i normal chrome that is installed in my pc i like may video and like stay forever but in selenium undetected i can just login but tiktok not letting me to like

i use this code same thing not lett me to like

d.findelement(By.id( "id")).click();

fysh711426 commented 2 years ago

Ok, I understand what you mean.

Can you put some code about UndetectedChromeDriver?

umari06 commented 2 years ago

i dont understand what you mean

fysh711426 commented 2 years ago

I need your test code, maybe I can find some clues from this, for example some options may be detected by website. --disable-gpu

umari06 commented 2 years ago
using System;
using OpenQA.Selenium;
using OpenQA.Selenium.Support;
using OpenQA.Selenium.Chrome;
using SeleniumUndetectedChromeDriver;

namespace cns_console
{
    internal class Program
    {
        static void Main(string[] args)
        {
            var driverExecutablePath = $@"C:\SeleniumProfiles\chromedriver.exe";
            var options = new ChromeOptions();
            options.AddArgument(@"--user-data-dir=C:\SeleniumProfiles\testundec");
            options.AddArgument("--mute-audio");
            options.AddArgument("--disable-gpu");
            options.AddArgument("--disable-dev-shm-usage"); // i remove 3 option same detected
            using var driver = UndetectedChromeDriver.Create( options: options, driverExecutablePath: driverExecutablePath);

            driver.GoToUrl("");              
            ...
        }
    }
}

also i try in python

import undetected_chromedriver as webdriver
import time

if __name__ == '__main__': 
    options = webdriver.ChromeOptions()
    options.add_argument('user-data-dir=C:\\SeleniumProfile\\test1')
    options.add_argument('profile-directory=Profile 1')
    options.page_load_strategy = "none"
    driver = webdriver.Chrome(executable_path=r'C:\SeleniumProfiles\chromedriver.exe', options=options)
    time.sleep(1)
    driver.get('')
    time.sleep(10)
    ...

not working for me after i click LIKE button tiktok detected and remove like auto after few sec

fysh711426 commented 1 year ago

I try it.

This is a problem with --disable-gpu.

I released a new package, you can try it.

PM> Install-Package Selenium.UndetectedChromeDriver -Version 1.0.6

Don't use any options.

var userDataDir = @"C:\SeleniumProfiles\testundec";
using var driver = UndetectedChromeDriver.Create(
    userDataDir: userDataDir,
    driverExecutablePath: driverExecutablePath);