Download and save an image automatically using Selenium WebDriver

0

I'm trying to download the Captcha image and save it through a WebDriver. Problem is when you click "Save". Does anyone know how I can do this?

staticvoidMain(string[]args){vardriver=newInternetExplorerDriver();driver.Navigate().GoToUrl("http://lattes.cnpq.br/8908009613435024");

        Console.Write(driver.CurrentWindowHandle);

        Console.Write("\nDigite a Captcha.\n");

        IWebElement imagem = driver.FindElementById("image_captcha");

        Actions action = new Actions(driver);
        action.ContextClick(imagem).Build().Perform();
        action.SendKeys("s").Build().Perform();

        Thread.Sleep(1000);

        IAlert alert = driver.SwitchTo().Alert();
        alert.SendKeys("foto1");

        driver.SwitchTo().Alert().Accept();


        var captcha = Console.ReadLine();

        driver.FindElementById("informado").SendKeys(captcha);

        IWebElement botao = driver.FindElementById("btn_validar_captcha");
        botao.Click();

        driver.Navigate().Refresh();

        var coisa = driver.PageSource;

        driver.Quit();
        Console.WriteLine();
        Console.Read();
    }
    
asked by anonymous 24.04.2018 / 05:56

0 answers