Selenium does not find element

Asked

Viewed 240 times

1

Follow the code. Selenium does not find the element:

package test;

import java.util.concurrent.TimeUnit;
import org.junit.AfterClass;
import org.junit.BeforeClass;
import org.junit.Test;
import org.openqa.selenium.By;
import org.openqa.selenium.WebDriver;
import org.openqa.selenium.chrome.ChromeDriver;
import org.openqa.selenium.support.ui.WebDriverWait;

public class pages {
    static WebDriver navegador;

    @BeforeClass
    public static void abrirNavegador() {

System.setProperty("webdriver.chrome.driver", "C:\\Automacao\\chromedriverV36_win32\\chromedriver.exe");

        navegador = new ChromeDriver();

        navegador.manage().timeouts().implicitlyWait(5, TimeUnit.SECONDS);

        navegador.get("https://www.centraldacorrida.com.br/");

        navegador.manage().window().maximize();

    }

    @Test
    public void paginaLogin() {

    navegador.findElement(By.name("j_username")).sendKeys("C001104");

    }

    @AfterClass
    public static void posCondicao() {
        // navegador.close();
    }
}

Trace error:

org.openqa.selenium.NoSuchElementException: no such element: Unable to locate element: {"method":"name","selector":"j_username"}

1 answer

0

Say little guy, blz ? Have you tried to find the element by xpath? for example:

navegador.findElement(By.xpath("//div[@name='j_username']").sendKeys("C001104");

Browser other questions tagged

You are not signed in. Login or sign up in order to post.