I'm trying to manipulate "chrome://downloads/
" URL using Selenium, my objective is to start a download, make sure that download get start and cancel the download. But I´m not able to get the values of the downloads or cancel.
It says that my id isn't correct, but I'm pretty sure that its correct. Does anyone know if there any restriction to this kind of page?
My code is --
using System;
using System.IO;
using System.Net;
using System.Net.Sockets;
using System.Text.RegularExpressions;
using System.Threading;
using OpenQA.Selenium.Chrome;
using OpenQA.Selenium.Firefox;
namespace SitesApplications
{
class Program
{
static void Main(string[] args)
{
BrowseUrl.driver = new ChromeDriver();
//ChromeOptions TESTE = new ChromeOptions();
//TESTE.AddArgument("--disable-privacy");
FileDownload teste = new FileDownload("http://centos.ufes.br/7/isos/x86_64/CentOS-7-x86_64-Everything-1708.iso", 60);
teste.gotoDownloadList("chrome://downloads/", 60);
//ChromeWebElement haha = new ChromeWebElement(BrowseUrl.DriverChrome, "pause-or-resume");
////haha.Clicks(20);
//haha.Cliquei(20);
teste.CancelaTeste(10);
}
}
And the program Calls That
using OpenQA.Selenium;
using OpenQA.Selenium.Support.PageObjects;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace SitesApplications
{
class FileDownload
{
/// <summary>
/// Enta no link direto para o download.
/// </summary>
/// <param name="Url">Link de destino para o download.</param>
/// <param name="time">Tempo maximo para abertura da pagina.</param>
public FileDownload(string Url, int time)
{
BrowseUrl CentOs = new BrowseUrl(Url, time);
PageFactory.InitElements(BrowseUrl.driver, this);
}
public void gotoDownloadList(string url, int timeout)
{
BrowseUrl downList = new BrowseUrl(url, timeout);
PageFactory.InitElements(BrowseUrl.driver, this);
}
private bool barra_prog;
public bool barraprog
{
get { return barra_prog; }
}
// Cancela Download
[FindsBy(How = How.TagName, Using = "Cancelar")]
public IWebElement btnCancelD { get; set; }
// Status do Download
[FindsBy(How = How.Id, Using = "description")]
public IWebElement status { get; set; }
/// Cancela teste de download
public bool CancelaTeste(int timeout)
{
BrowseUrl.driver.SwitchTo().Window("");
//barra_prog = GetElements.GetCheckBoxAttribute(status, timeout);
btnCancelD.Clicks(timeout);
//BrowseUrl.driver.Close();
//BrowseUrl.driver.Quit();
return barra_prog;
}
}