I'm trying to manipulate "chrome://downloads/" URL using Selenium.
My objective is to
- Start a download,
- Make sure that download get start
- Cancel the download
But the problem is that I´m not able to get the values of the downloads or cancel.
It shows an error: that my id isn't correct. Does anyone know if there any restriction to this kind of page?
Below is my code:
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("https://img.cs.montana.edu/linux/centos/7.4.1708/isos/x86_64/", 60);
teste.gotoDownloadList("chrome://downloads/", 60);
//ChromeWebElement haha = new ChromeWebElement(BrowseUrl.DriverChrome, "pause-or-resume");
////haha.Clicks(20);
//haha.Cliquei(20);
teste.CancelaTeste(10);
}
}
Program Calls
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; }