title: Pass item from listbox to selenium webdriver
body: <p>I want to be able to pass items from listbox to a webdriver. Basically i have a list of URLs being added to the listbox via a text file and then i want to pass each line of the listbox to selenium webdriver so i can run a test. from what i can gather i need to make the each item in the listbox a string somehow and then pass that string to the webdriver. i am not sure how to go about this. any help would be much appreciated.</p>
  <p>this is the code for the openFileDialog in the form.cs to load the text file into the Listbox</p>
  <pre><code>private void UrlFilePickerBtn_Click(object sender, EventArgs e)
      {
          var filePath = string.Empty;
  
          openFileDialog.InitialDirectory = Application.StartupPath;
          openFileDialog.Filter = &quot;txt files (*.txt)|*.txt|All Files (*.*)|*.*&quot;;
          openFileDialog.FilterIndex = 2;
          openFileDialog.RestoreDirectory = true;
  
         if(openFileDialog.ShowDialog() == DialogResult.OK)
          {
              filePath = openFileDialog.FileName;
  
              var fileStream = openFileDialog.OpenFile();
              StreamReader reader = new StreamReader(fileStream);
              {
                  string line;
                  while ((line = reader.ReadLine()) != null) {
                      LSlistBox.Items.Add(line);
                  }
              }
          }
      }
  </code></pre>
  <p>and this is in a seperate class where i want to be able to call the listbox item to a string i guess and the string will replace the current URL</p>
  <pre><code>public void OpenBrowsers()
      {
          Console.WriteLine(&quot;Normal Button Starting Browsers&quot;);
          chromeDriver = DriverClass.GetDriver(&quot;Chrome&quot;);
          foxDriver = DriverClass.GetDriver(&quot;Firefox&quot;);
          edgeDriver = DriverClass.GetDriver(&quot;Edge&quot;);
  
          chromeDriver.Navigate().GoToUrl(&quot;http://www.google.co.uk&quot;);
  
              
      }
  </code></pre>
  <p>hope that makes sense</p>