fysh711426 / UndetectedChromeDriver

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

not starting in headless mode #50

Open hakeatos opened 1 year ago

hakeatos commented 1 year ago

simple 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; using System.Threading.Tasks; using System.Windows.Forms; using OpenQA.Selenium; using OpenQA.Selenium.Chrome; using SeleniumUndetectedChromeDriver; namespace WindowsFormsApp1 { public partial class Form1 : Form { public Form1() { InitializeComponent(); }

    private void Form1_Load(object sender, EventArgs e)
    {

    }

    private async void button1_Click(object sender, EventArgs e)
    {
        var options = new ChromeOptions();
        //options.AddArguments("--window-size=600,600");

//options.AddArguments("--headless"); using (var driver = UndetectedChromeDriver.Create( driverExecutablePath: await new ChromeDriverInstaller().Auto(), // hideCommandPromptWindow: true, headless: true, options: options

            )

            )

        {
            driver.Navigate().GoToUrl("https://www.twitch.tv/axtlol");
            Thread.Sleep(7000);
            var screenshot = driver.GetScreenshot();
            screenshot.SaveAsFile("screenshot.png", ScreenshotImageFormat.Png);
        }

    }
}

}

fysh711426 commented 1 year ago

Use options.AddArguments("--window-size=600,600") and change

driver.Navigate().GoToUrl("https://www.twitch.tv/axtlol");

to

driver.GoToUrl("https://www.twitch.tv/axtlol");