samedi 6 novembre 2021

getting a random input from a list that has been placed into a textbox with C# and Selenium

Am trying to solve this issue I have for work I saw that selenium is quite useful and I wanted to save time and energy doing the same task everyday so I tried making a really basic way to solve the current issue I have with C# and Selenium I need to do the following. I'm trying to figure out how I could connect a textbox (multiple text input) to then randomly pick one and send it to a webpage. This is my code so far:

namespace emails
{

public partial class MainWindow : Window
{
    public MainWindow()
    {
        InitializeComponent();
    }

    private void TextBox_TextChanged(object sender, TextChangedEventArgs e)
    {
        //textbox input
        string quest = question1.Text;

      
        var random = new Random();
        var names = new List<string> { question1.Text};
        int index = random.Next(names.Count);
    }

    private void Button_Click(object sender, RoutedEventArgs e)
    {

        
        ChromeDriver driver = new ChromeDriver(@"C:\webdrivers");
        ChromeDriver drv; Thread th;
        string url = "https://accounts.google.com/signin/v2/identifier?continue=https%3A%2F%2Fmail.google.com%2Fmail%2F&service=mail&sacu=1&rip=1&flowName=GlifWebSignIn&flowEntry=ServiceLogin";
         
        
        driver.Navigate().GoToUrl(url);
        driver.FindElement(By.ClassName("whsOnd")).SendKeys(question1.Text); Thread.Sleep(2000);

        


    }
}
}

I tried this but as expected this would just send the whole textbox input.




Aucun commentaire:

Enregistrer un commentaire