Unpick Chrome from running tests with automated software

0

I tried to implement Chrome Options in my script to delete that yellow information bar from Chrome, which is displayed every time we run automated tests (" Chrome is being controlled by automated test software " ), but the result I had was the display of two windows of Chrome: one minimized, displaying the infobar, and another maximized without the display of the infobar, where my script was executed.

Please, could you guide me where I'm going wrong? I have made several modifications but I have not been able to correct this double opening of the browser:

using OpenQA.Selenium;
using OpenQA.Selenium.Chrome;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading;
using System.Threading.Tasks;
namespace navegador.PageObjects
{
    public class acessaSite
    {
    public IWebDriver driver;
        public acessaSite(IWebDriver driver)
        {
        this.driver = driver;
        }
        public void acessaURL()
        {

         var options = new ChromeOptions();
         options.AddArguments("--disable-infobars");
         options.AddUserProfilePreference("credentials_enable_service", false);
         options.AddUserProfilePreference("profile.password_manager_enabled", false);
         driver = new ChromeDriver(options);

        driver.Manage().Window.Maximize();
        driver.Navigate().GoToUrl("https://meusite.com.br");
        Thread.Sleep(1000);
        }
    }
}

Thank you!

    
asked by anonymous 08.08.2017 / 12:54

2 answers

0

Issue solved! The final code is:

[TestFixture]
public class Login
{
IWebDriver driver = null;
public capturaImagem tiraScreenshot;
public acessaSite navegador;
public LoginPositivo testePositivo;
public LoginNegativo testeNegativo;
public sair sessao;

    public Login()
    {
    ChromeOptions options = new ChromeOptions();
    options.AddArguments("--disable-infobars");
    options.AddArguments("start-maximized");
    driver = new ChromeDriver(options);

    tiraScreenshot = new capturaImagem(driver);
    navegador = new acessaSite(driver);
    testePositivo = new LoginPositivo(driver);
    testeNegativo = new LoginNegativo(driver);
    sessao = new sair(driver);
    }

    [TearDown]
    public void DepoisDosTestes()
    {
    driver.Close();
    }

    [Test]
    public void AutomacaoLogin()
    {
    navegador.acessaURL();
    testePositivo.UsuarioSenhaValidos();
    sessao.FazLogoff();
    testeNegativo.CamposEmBranco();
    testeNegativo.UsuarioInvalido();
    testeNegativo.SenhaInvalida();
    }
}
public class acessaSite
{
public IWebDriver driver;
public capturaImagem tiraScreenshot;

    public acessaSite(IWebDriver driver)
    {
    tiraScreenshot = new capturaImagem(driver);
    this.driver = driver;
    }

    public void acessaURL()
    {
    driver.Navigate().GoToUrl("https://www.meusite.com.br");
    Thread.Sleep(1000);
    tiraScreenshot.salvaImagem();
    Thread.Sleep(200);
    }
    
08.08.2017 / 20:28
0

Hi, try instantiating Chrome options as follows:

            ChromeOptions options = new ChromeOptions();
            options.AddArguments("--disable-infobars");
            driver = new ChromeDriver(options);

This is a case where you must explicitly use the variable type to pass the correct intent to the driver variable.

I'm putting this part to best illustrate what I've answered below, try to see if it works this way:

    var options = new ChromeOptions();
    options.AddArguments("--disable-infobars");
    options.AddArguments("start-maximized"); //Isso deve iniciar o chrome maximizado
    options.AddUserProfilePreference("credentials_enable_service", false);
    options.AddUserProfilePreference("profile.password_manager_enabled", false);
    driver = new ChromeDriver(options);

    //driver.Manage().Window.Maximize();
    driver.Navigate().GoToUrl("https://meusite.com.br");
    Thread.Sleep(1000);
    
08.08.2017 / 13:27