I'm developing bot. He is working normally when headless mode is set to false. Whenever I start it with headless mode set to true, it throws timeout errors because it didn't find my selectors. I thought it would be maybe because of different resolution in both modes. So I set static default viewport. It fixed nothing.
Is it even possible to click with pupeeteer in headless mode? I would like to achieve that so I don't have multiple chromes open.
Creating browser
_browser = await Puppeteer.LaunchAsync(new LaunchOptions
{
Headless = true,
ExecutablePath = @"C:\Program Files (x86)\Google\Chrome\Application\chrome.exe",
Args = new[] { "--disable-web-security", "--disable-infobars" },
DefaultViewport = new ViewPortOptions { Height = 1080, Width = 1920},
}) ;
var pagesAsync = await _browser.PagesAsync();
_page = pagesAsync.FirstOrDefault();
const string logInButtom = "#__layout > div > nav > div.uinfo-wrapper.flex > div.login-btn-wrap > button";
await _page.WaitForSelectorAsync(logInButtom);
await _page.ClickAsync(logInButtom);
System.Threading.Thread.Sleep(1500);
Debug.WriteLine("Succesfull login show");
Here is piece of code that works headless = false. Doesnt work headless = true
await _page.WaitForSelectorAsync(logInButtom); throws time out.