5

How to switch between current opened tab to a new tab opened after clicking on a button, using dotnetbrowser? Is it possible?

I'm trying to download a PDF file from a page, that is displayed on a new tab after clicking on a button on the home page. However, all my attempts to retrieve the PDF failed (I've already added the CustomPluginFilter).

EDIT: Here is the code I use, after getting the page containing the PDF button (after clicking it, a new tab is opened displaying the content of the pdf)

public class CustomPluginFilter : PluginFilter
{
    public bool IsPluginAllowed (PluginInfo pluginInfo)
    {
        if (pluginInfo.MimeTypes.Contains("application/pdf"))
        {
            return false;
        }
        return pluginInfo.MimeTypes.Contains("application/pdf");
    }
}

DotNetBrowser.BrowserContextParams parameters = new DotNetBrowser.BrowserContextParams(directory);
            DotNetBrowser.BrowserContext context = new DotNetBrowser.BrowserContext(parameters);
            Browser browser = DotNetBrowser.BrowserFactory.Create(context);

this is where I make the requests to get the page with the button, it is working until here. Next is the steps to get the PDF

 browser.PluginManager.PluginFilter = new CustomPluginFilter();

        SampleDownloadHandler downloadHandler = new SampleDownloadHandler();
        browser.DownloadHandler               = downloadHandler;

        DOMDocument document = browser.GetDocument();
        XPathResult xpath    = document.Evaluate(".//table[contains(@id, \"formulario:tabelaIE\")]//tr//a", XPathResultType.FIRST_ORDERED_NODE_TYPE);
        DOMElement  element  = xpath.SingleNode as DOMElement;
        element.Click();
PamelaTabak
  • 187
  • 1
  • 8

0 Answers0