7
respostas

[Dúvida] Erro ao rodar projeto URL não abre

Estou com problemas para rodar a automação, ao rodar a tela do google é iniciada mais não abre a tela que eu pedi no teste oq devo fazer?

inseri o código e abru a pagina do google, mais não a pagina específica do teste

7 respostas

Oi!

Talvez seja por conta da ordem de configurações no seu código. Altere da seguinte maneira e veja se funciona:

ChromeOptions options = new ChromeOptions();
options.addArguments("--disable-cloud-management");
WebDriver driver = new ChromeDriver(options);

int minutos = 5;
long milisegundos = minutos * 60 * 1000;

driver.get("https://www.globo.com");

try {
    Thread.sleep(milisegundos);
} catch (InterruptedException e) {
    e.printStackTrace();
}

driver.quit();

Mesmo alterando da forma acima estou recebendo esse erro:

org.openqa.selenium.WebDriverException: Timed out waiting for driver server to start. Build info: version: '3.141.59', revision: 'e82be7d358', time: '2018-11-14T08:17:03' System info: host: 'GMEPN005846', ip: '192.168.15.151', os.name: 'Windows 11', os.arch: 'amd64', os.version: '10.0', java.version: '17.0.10' Driver info: driver.version: ChromeDriver at org.openqa.selenium.remote.service.DriverService.waitUntilAvailable(DriverService.java:202) at org.openqa.selenium.remote.service.DriverService.start(DriverService.java:188) at org.openqa.selenium.remote.service.DriverCommandExecutor.execute(DriverCommandExecutor.java:79) at org.openqa.selenium.remote.RemoteWebDriver.execute(RemoteWebDriver.java:552) at org.openqa.selenium.remote.RemoteWebDriver.startSession(RemoteWebDriver.java:213) at org.openqa.selenium.remote.RemoteWebDriver.(RemoteWebDriver.java:131) at org.openqa.selenium.chrome.ChromeDriver.(ChromeDriver.java:181) at org.openqa.selenium.chrome.ChromeDriver.(ChromeDriver.java:168) at org.openqa.selenium.chrome.ChromeDriver.(ChromeDriver.java:123) at RoboNavegador.abrirNavegador.abrirGoogle(abrirNavegador.java:14) at java.base/jdk.internal.reflect.NativeMethodAccessorImpl.invoke0(Native Method) at java.base/jdk.internal.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:77) at java.base/jdk.internal.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43) at java.base/java.lang.reflect.Method.invoke(Method.java:568) at org.junit.runners.model.FrameworkMethod$1.runReflectiveCall(FrameworkMethod.java:59) at org.junit.internal.runners.model.ReflectiveCallable.run(ReflectiveCallable.java:12) at org.junit.runners.model.FrameworkMethod.invokeExplosively(FrameworkMethod.java:56) at org.junit.internal.runners.statements.InvokeMethod.evaluate(InvokeMethod.java:17) at org.junit.runners.ParentRunner$3.evaluate(ParentRunner.java:306) at org.junit.runners.BlockJUnit4ClassRunner$1.evaluate(BlockJUnit4ClassRunner.java:100) at org.junit.runners.ParentRunner.runLeaf(ParentRunner.java:366) at org.junit.runners.BlockJUnit4ClassRunner.runChild(BlockJUnit4ClassRunner.java:103) at org.junit.runners.BlockJUnit4ClassRunner.runChild(BlockJUnit4ClassRunner.java:63) at org.junit.runners.ParentRunner$4.run(ParentRunner.java:331) at org.junit.runners.ParentRunner$1.schedule(ParentRunner.java:79) at org.junit.runners.ParentRunner.runChildren(ParentRunner.java:329) at org.junit.runners.ParentRunner.access$100(ParentRunner.java:66) at org.junit.runners.ParentRunner$2.evaluate(ParentRunner.java:293) at org.junit.runners.ParentRunner$3.evaluate(ParentRunner.java:306) at org.junit.runners.ParentRunner.run(ParentRunner.java:413) at org.eclipse.jdt.internal.junit4.runner.JUnit4TestReference.run(JUnit4TestReference.java:93) at org.eclipse.jdt.internal.junit.runner.TestExecution.run(TestExecution.java:40) at org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.runTests(RemoteTestRunner.java:529) at org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.runTests(RemoteTestRunner.java:757) at org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.run(RemoteTestRunner.java:452) at org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.main(RemoteTestRunner.java:210) Caused by: org.openqa.selenium.net.UrlChecker$TimeoutException: Timed out waiting for [http://localhost:36910/status] to be available after 20007 ms at org.openqa.selenium.net.UrlChecker.waitUntilAvailable(UrlChecker.java:100) at org.openqa.selenium.remote.service.DriverService.waitUntilAvailable(DriverService.java:197) ... 35 more Caused by: java.util.concurrent.TimeoutException at java.base/java.util.concurrent.FutureTask.get(FutureTask.java:204) at com.google.common.util.concurrent.SimpleTimeLimiter.callWithTimeout(SimpleTimeLimiter.java:156) at org.openqa.selenium.net.UrlChecker.waitUntilAvailable(UrlChecker.java:75) ... 36 more

Com código inserido conforme exemplo acima

troquei o código só para isso:

package RoboNavegador;

import org.junit.Test; import org.openqa.selenium.WebDriver; import org.openqa.selenium.chrome.ChromeDriver; import org.openqa.selenium.chrome.ChromeOptions;

public class abrirNavegador {

@Test
public void abrirGoogle() {
    System.setProperty("webdriver.chrome.driver", "C:\\Users\\jamilly.camargo\\eclipse-workspace\\RoboAutomacaoTokio\\Navegador\\chrome.exe");
     
     ChromeOptions options = new ChromeOptions();
     options.addArguments("--disable-cloud-management");
     WebDriver driver = new ChromeDriver(options);

     int minutos = 5;
     long milisegundos = minutos * 60 * 1000;

     driver.get("https://www.globo.com");

     try {
         Thread.sleep(milisegundos);
     } catch (InterruptedException e) {
         e.printStackTrace();
     }

     driver.quit();
}	 
}

e ainda sim recebi esse mesmo erro

Deixa o código do jeito "padrão" e veja se acontece o erro:

System.setProperty("webdriver.chrome.driver", "C:\\Users\\jamilly.camargo\\eclipse-workspace\\RoboAutomacaoTokio\\Navegador\\chrome.exe");

WebDriver driver = new ChromeDriver();
driver.get("https://www.globo.com");

driver.quit();

Mesmo erro:

org.openqa.selenium.WebDriverException: Timed out waiting for driver server to start. Build info: version: '3.141.59', revision: 'e82be7d358', time: '2018-11-14T08:17:03' System info: host: 'GMEPN005846', ip: '192.168.15.151', os.name: 'Windows 11', os.arch: 'amd64', os.version: '10.0', java.version: '17.0.10' Driver info: driver.version: ChromeDriver at org.openqa.selenium.remote.service.DriverService.waitUntilAvailable(DriverService.java:202) at org.openqa.selenium.remote.service.DriverService.start(DriverService.java:188) at org.openqa.selenium.remote.service.DriverCommandExecutor.execute(DriverCommandExecutor.java:79) at org.openqa.selenium.remote.RemoteWebDriver.execute(RemoteWebDriver.java:552) at org.openqa.selenium.remote.RemoteWebDriver.startSession(RemoteWebDriver.java:213) at org.openqa.selenium.remote.RemoteWebDriver.(RemoteWebDriver.java:131) at org.openqa.selenium.chrome.ChromeDriver.(ChromeDriver.java:181) at org.openqa.selenium.chrome.ChromeDriver.(ChromeDriver.java:168) at org.openqa.selenium.chrome.ChromeDriver.(ChromeDriver.java:123) at RoboNavegador.abrirNavegador.abrirGoogle(abrirNavegador.java:15) at java.base/jdk.internal.reflect.NativeMethodAccessorImpl.invoke0(Native Method) at java.base/jdk.internal.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:77) at java.base/jdk.internal.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43) at java.base/java.lang.reflect.Method.invoke(Method.java:568) at org.junit.runners.model.FrameworkMethod$1.runReflectiveCall(FrameworkMethod.java:59) at org.junit.internal.runners.model.ReflectiveCallable.run(ReflectiveCallable.java:12) at org.junit.runners.model.FrameworkMethod.invokeExplosively(FrameworkMethod.java:56) at org.junit.internal.runners.statements.InvokeMethod.evaluate(InvokeMethod.java:17) at org.junit.runners.ParentRunner$3.evaluate(ParentRunner.java:306) at org.junit.runners.BlockJUnit4ClassRunner$1.evaluate(BlockJUnit4ClassRunner.java:100) at org.junit.runners.ParentRunner.runLeaf(ParentRunner.java:366) at org.junit.runners.BlockJUnit4ClassRunner.runChild(BlockJUnit4ClassRunner.java:103) at org.junit.runners.BlockJUnit4ClassRunner.runChild(BlockJUnit4ClassRunner.java:63) at org.junit.runners.ParentRunner$4.run(ParentRunner.java:331) at org.junit.runners.ParentRunner$1.schedule(ParentRunner.java:79) at org.junit.runners.ParentRunner.runChildren(ParentRunner.java:329) at org.junit.runners.ParentRunner.access$100(ParentRunner.java:66) at org.junit.runners.ParentRunner$2.evaluate(ParentRunner.java:293) at org.junit.runners.ParentRunner$3.evaluate(ParentRunner.java:306) at org.junit.runners.ParentRunner.run(ParentRunner.java:413) at org.eclipse.jdt.internal.junit4.runner.JUnit4TestReference.run(JUnit4TestReference.java:93) at org.eclipse.jdt.internal.junit.runner.TestExecution.run(TestExecution.java:40) at org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.runTests(RemoteTestRunner.java:529) at org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.runTests(RemoteTestRunner.java:757) at org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.run(RemoteTestRunner.java:452) at org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.main(RemoteTestRunner.java:210) Caused by: org.openqa.selenium.net.UrlChecker$TimeoutException: Timed out waiting for [http://localhost:8573/status] to be available after 20013 ms at org.openqa.selenium.net.UrlChecker.waitUntilAvailable(UrlChecker.java:100) at org.openqa.selenium.remote.service.DriverService.waitUntilAvailable(DriverService.java:197) ... 35 more Caused by: java.util.concurrent.TimeoutException at java.base/java.util.concurrent.FutureTask.get(FutureTask.java:204) at com.google.common.util.concurrent.SimpleTimeLimiter.callWithTimeout(SimpleTimeLimiter.java:156) at org.openqa.selenium.net.UrlChecker.waitUntilAvailable(UrlChecker.java:75) ... 36 more

Somente com o código acima

Geralmente está associado com problemas de versões. No seu log vi que você está utilizando o Java 17, então altere a dependência do chrome-driver no pom.xml do projeto para:

<dependency>
    <groupId>org.seleniumhq.selenium</groupId>
    <artifactId>selenium-chrome-driver</artifactId>
    <version>4.20.0</version>
</dependency>

E baixe o driver do chrome mais recente também: https://storage.googleapis.com/chrome-for-testing-public/124.0.6367.91/win64/chrome-win64.zip

troquei a dependência e baixei o novo chrome driver !Não abriu o navegador](https://cdn1.gnarususercontent.com.br/1/4164530/f2e65c48-a6a5-42fa-87d6-dbc79480b629.png)

E recebi essa mensagem de erro:

java.lang.NoClassDefFoundError: org/openqa/selenium/interactions/HasTouchScreen at java.base/java.lang.ClassLoader.defineClass1(Native Method) at java.base/java.lang.ClassLoader.defineClass(ClassLoader.java:1017) at java.base/java.security.SecureClassLoader.defineClass(SecureClassLoader.java:150) at java.base/jdk.internal.loader.BuiltinClassLoader.defineClass(BuiltinClassLoader.java:862) at java.base/jdk.internal.loader.BuiltinClassLoader.findClassOnClassPathOrNull(BuiltinClassLoader.java:760) at java.base/jdk.internal.loader.BuiltinClassLoader.loadClassOrNull(BuiltinClassLoader.java:681) at java.base/jdk.internal.loader.BuiltinClassLoader.loadClass(BuiltinClassLoader.java:639) at java.base/jdk.internal.loader.ClassLoaders$AppClassLoader.loadClass(ClassLoaders.java:188) at java.base/java.lang.ClassLoader.loadClass(ClassLoader.java:525) at RoboNavegador.abrirNavegador.abrirGoogle(abrirNavegador.java:15) at java.base/jdk.internal.reflect.NativeMethodAccessorImpl.invoke0(Native Method) at java.base/jdk.internal.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:77) at java.base/jdk.internal.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43) at java.base/java.lang.reflect.Method.invoke(Method.java:568) at org.junit.runners.model.FrameworkMethod$1.runReflectiveCall(FrameworkMethod.java:59) at org.junit.internal.runners.model.ReflectiveCallable.run(ReflectiveCallable.java:12) at org.junit.runners.model.FrameworkMethod.invokeExplosively(FrameworkMethod.java:56) at org.junit.internal.runners.statements.InvokeMethod.evaluate(InvokeMethod.java:17) at org.junit.runners.ParentRunner$3.evaluate(ParentRunner.java:306) at org.junit.runners.BlockJUnit4ClassRunner$1.evaluate(BlockJUnit4ClassRunner.java:100) at org.junit.runners.ParentRunner.runLeaf(ParentRunner.java:366) at org.junit.runners.BlockJUnit4ClassRunner.runChild(BlockJUnit4ClassRunner.java:103) at org.junit.runners.BlockJUnit4ClassRunner.runChild(BlockJUnit4ClassRunner.java:63) at org.junit.runners.ParentRunner$4.run(ParentRunner.java:331) at org.junit.runners.ParentRunner$1.schedule(ParentRunner.java:79) at org.junit.runners.ParentRunner.runChildren(ParentRunner.java:329) at org.junit.runners.ParentRunner.access$100(ParentRunner.java:66) at org.junit.runners.ParentRunner$2.evaluate(ParentRunner.java:293) at org.junit.runners.ParentRunner$3.evaluate(ParentRunner.java:306) at org.junit.runners.ParentRunner.run(ParentRunner.java:413) at org.eclipse.jdt.internal.junit4.runner.JUnit4TestReference.run(JUnit4TestReference.java:93) at org.eclipse.jdt.internal.junit.runner.TestExecution.run(TestExecution.java:40) at org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.runTests(RemoteTestRunner.java:529) at org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.runTests(RemoteTestRunner.java:757) at org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.run(RemoteTestRunner.java:452) at org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.main(RemoteTestRunner.java:210) Caused by: java.lang.ClassNotFoundException: org.openqa.selenium.interactions.HasTouchScreen at java.base/jdk.internal.loader.BuiltinClassLoader.loadClass(BuiltinClassLoader.java:641) at java.base/jdk.internal.loader.ClassLoaders$AppClassLoader.loadClass(ClassLoaders.java:188) at java.base/java.lang.ClassLoader.loadClass(ClassLoader.java:525) ... 36 more