Selenium no works with Google headless mode: Unable to locate element

0

I need to use google headless, but I have this error

OpenQA.Selenium.NoSuchElementException HResult=0x80131500 Message=no such element: Unable to locate element: {"method":"name","selector":"identifier"} (Session info: headless chrome=74.0.3729.108) (Driver info: chromedriver=74.0.3729.6 (255758eccf3d244491b8a1317aa76e1ce10d57e9-refs/branch-heads/3729@{#29}),platform=Windows NT 10.0.17763 x86_64) Source=WebDriver

my code config:

 void Run()
 {
// Setup Selenium
            chromeOptions = new ChromeOptions();
            chromeOptions.AddArguments("--no-sandbox");
            chromeOptions.AddArguments("--headless");
            chromeOptions.AddArguments("--window-size=1280,800");
            chromeOptions.AddArguments("disable-gpu");
            driver = new ChromeDriver(chromeOptions);

            // Perform the Login actions


            YoutubeLogin();
}
public void YoutubeLogin()
        {

            Thread.Sleep(2000);
            driver.Navigate().GoToUrl("https://www.youtube.com/account");
            Thread.Sleep(1000);
            driver.FindElement(By.Name("identifier")).SendKeys(youtubeEmail);
            Thread.Sleep(1000);
            driver.FindElement(By.ClassName("CwaK9")).Click();
            Thread.Sleep(1000);
            driver.FindElement(By.Name("password")).SendKeys(youtubePassword);
            Thread.Sleep(1000);
            driver.FindElement(By.ClassName("CwaK9")).Click();
            Thread.Sleep(1000);
        }

on the line

driver.FindElement(By.Name("identifier")).SendKeys(youtubeEmail);
c#
selenium
selenium-chromedriver
asked on Stack Overflow Apr 29, 2019 by Gexur

0 Answers

Nobody has answered this question yet.


User contributions licensed under CC BY-SA 3.0