C#Selenium Chromedriver代理身份验证

时间:2020-09-04 17:47:25

标签: selenium

Visual Studio 2019 C#,代理身份验证始终无法正常工作。我用u:p@1.2.3.4:80 ...有很多方法。这对于浏览器自动化非常重要。互联网对此没有正确的方法。抱歉...对于stackoverflow规则:看来您的帖子大部分是代码;请添加更多详细信息。看起来您的帖子大部分是代码;请添加更多详细信息。看起来您的帖子大部分是代码;请添加更多详细信息。看起来您的帖子大部分是代码;请添加更多详细信息。看起来您的帖子大部分是代码;请添加更多详细信息。看起来您的帖子大部分是代码;请添加更多详细信息。看起来您的帖子大部分是代码;请添加更多详细信息。看起来您的帖子大部分是代码;请添加更多详细信息。

using OpenQA.Selenium;
using OpenQA.Selenium.Chrome;
using OpenQA.Selenium.Support.UI;
using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Windows.Forms;
using System.Threading;
namespace WindowsFormsApp5
{
    public partial class Form1 : Form
    {
        Thread bnd;
        public Form1()
        {
            InitializeComponent();
            CheckForIllegalCrossThreadCalls = false;
        }
        
        private void button1_Click(object sender, EventArgs e)
        {
            bnd = new Thread(hizlibasla);
            bnd.Start();
        }


        private void hizlibasla()
        {
            ChromeOptions proxy = new ChromeOptions();
            proxy.AddArgument("--proxy-server=14.131.0.1:8080");
        
          
            IWebDriver driver = new ChromeDriver(proxy);
            driver.Navigate().GoToUrl("http://x.com/bot/y.php");
           

            //driver.SwitchTo().Alert().SetAuthenticationCredentials("er1", "1");
            /*
            var alert = driver.SwitchTo().Alert();

            alert.SetAuthenticationCredentials("er1", "1");

            alert.Accept();*/


        }

        private void button2_Click(object sender, EventArgs e)
        {
           
            //driver.Quit();
        }
    }
}

0 个答案:

没有答案