0

I make a program and it keeps open and close tabs SO when a new tab opened or closed, chrome show up again even if it minimize I need to keep it minimized This is my code:

                   ((IJavaScriptExecutor)driver).ExecuteScript("window.open();");
                    driver.SwitchTo().Window(driver.WindowHandles.Last());
                    try
                    {
                        try
                        {
                            driver.Manage().Timeouts().PageLoad = TimeSpan.FromSeconds(10);
                            driver.Navigate().GoToUrl(url);
                        }
                        catch (Exception r)
                        {
                            ((IJavaScriptExecutor)driver).ExecuteScript("return window.stop");
                        }


                        var streamdiv = obj.FindElement(driver, "content-audio_html5_api", Assistances.FindElementBy.ID, true);
                        if (streamdiv != null)
                        {
                            var streamurl = streamdiv.FindElement(By.XPath(".//source")).GetAttribute("src");
                            if ((streamurl != "" || streamurl != null) && streamurl != url.Remove(url.IndexOf('s'), 1))
                            {
                                row["streamURL"] = streamurl;
                            }
                        }
                    }
                    catch (Exception er)
                    {
                        row["streamURL"] = "";
                    }
                    try
                    {
                        string logo_url = driver.FindElement(By.XPath("//div[@class='song-image']//a//img")).GetAttribute("src");
                        row["logo_URL"] = logo_url;
                        obj.DownloadImage(logo_url);
                    }
                    catch (Exception e)
                    {

                    }
                    driver.Close();
                    driver.SwitchTo().Window(driver.WindowHandles.First());
  • 1
    You have headless mode in which you do not see browser at all. See https://stackoverflow.com/questions/53657215/running-selenium-with-headless-chrome-webdriver – Gaj Julije Dec 30 '20 at 09:44
  • Thx! I know about this. but I don't want to hide the browser, I just want when I click minimize to stay minimize @GajJulije – Manal El Sabbah Dec 30 '20 at 12:38
  • I do not see from your code. Where your browser is minimized or maximied. Can you try to use driver.get(URL). Check do you have any methods before your scenario like driver = initializeDriver(); driver.manage().window().maximize();// This will mximize – Gaj Julije Dec 30 '20 at 13:22

0 Answers0