How do I capture the text of a webpage with Selenium?

1

I need to create a default People Generator by using the link site with Selenium. This is the code I have for now:

 [TestFixture]  
 public class GeradorDePessoas
 {
    private IWebDriver driver;

    [SetUp]
    public void SetUp()
    {
        driver = new ChromeDriver();
        driver.Navigate().GoToUrl("https://www.4devs.com.br/gerador_de_pessoas");
    }

    [Test]
    public void DeveGerarUmaPessoa()
    {
        driver.FindElement(By.Name("sexo")).Click();

        SelectElement idade = new SelectElement(driver.FindElement(By.Name("idade")));
        idade.SelectByValue("20");
        driver.FindElement(By.Name("pontuacao")).Click();

        driver.FindElement(By.Id("bt_gerar_pessoa")).Click();


        driver.FindElement(By.XPath("//div[@id='nome']"));
    }

}  

My problem now is that I need to capture the information generated by the site and put them into variables in the program so that they can be called later in other tests. Can anyone help me with this? I have no idea which way to go from now on.

    
asked by anonymous 14.06.2018 / 18:16

1 answer

0

You can try:

driver.FindElement(By.XPath("//div[@id='nome']")).text;
    
29.06.2018 / 21:08