U
U
U_n_d_e_r2021-04-05 14:21:04
C++ / C#
U_n_d_e_r, 2021-04-05 14:21:04

How to implement Selenium threads?

I decided to implement multithreading on Selenium, but during the implementation there were errors associated with initialization. Here is an example of an error:
Argument 1: cannot convert from 'method group' to 'ParameterizedThreadStart' [lessons] I am
attaching the code.

using System;
using OpenQA.Selenium;
using OpenQA.Selenium.Chrome;
using System.Threading;
namespace lessons
{
    class Program
    {
        public void Main(string[] args)
        {
            IWebDriver driver = new ChromeDriver(); 
            driver.Navigate().GoToUrl(@"https://yandex.ru");
            for{
            var y = driver.FindElement(By.XPath("/html/body/div[4]/div/div/div/div[3]/div[5]/div[8]/div/div[1]")).GetAttribute("outerHTML");
             var htmlDoc = new HtmlDocument();
             htmlDoc.LoadHtml(y);
             var htmlBody = htmlDoc.DocumentNode.SelectSingleNode("//div");
             string z  = htmlBody.OuterHtml;
             string[] d = z.Split(' ','=','"');
             Thread OneHandes = new Thread(OneBoys);
             OneHandes.Start();
             }
        }
        public static void OneBoys(IWebDriver driver)
        {
             var apfa= driver.FindElement(By.XPath("/html/body/div[4]/div/div/div/div[3]/div[5]/div[8]/div/div[1]")).GetAttribute("outerHTML");
             var htmlDocalfa = new HtmlDocument();
             htmlDocalfa.LoadHtml(alfa);
             var htmlBodyalfa = htmlDoc.DocumentNode.SelectSingleNode("//div");
             string talfa  = htmlBody.OuterHtml;
             string[] dalfa = z.Split(' ','=','"');
        }
     }
}

Answer the question

In order to leave comments, you need to log in

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question