Browser doesn't pop up - Any idea what's happening? All IE, Chrome and Mozilla not popping up | Selenium Forum
C
Cheong Kah Seng Posted on 01/11/2020

Output when running DummyTestB

[RemoteTestNG] detected TestNG version 6.9.6
WARNING: An illegal reflective access operation has occurred
WARNING: Illegal reflective access by org.testng.xml.XMLParser (file:/C:/Users/Cheong%20Kah%20Seng/.m2/repository/org/testng/testng/6.9.6/testng-6.9.6.jar) to constructor com.sun.org.apache.xerces.internal.jaxp.SAXParserFactoryImpl()
WARNING: Please consider reporting this to the maintainers of org.testng.xml.XMLParser
WARNING: Use --illegal-access=warn to enable warnings of further illegal reflective access operations
WARNING: All illegal access operations will be denied in a future release
[TestNG] Running:
C:\Users\Cheong Kah Seng\AppData\Local\Temp\testng-eclipse--1140127300\testng-customsuite.xml

FAILED: testB
java.lang.NoSuchMethodError: 'void com.google.common.base.Preconditions.checkArgument(boolean, java.lang.String, int)'
at org.openqa.selenium.remote.service.DriverService$Builder.usingPort(DriverService.java:285)
at org.openqa.selenium.ie.InternetExplorerDriver.setupService(InternetExplorerDriver.java:242)
at org.openqa.selenium.ie.InternetExplorerDriver.<init>(InternetExplorerDriver.java:211)
at org.openqa.selenium.ie.InternetExplorerDriver.<init>(InternetExplorerDriver.java:150)
at com.qtpselenium.core.ddf.base.BaseTest.openBrowser(BaseTest.java:20)
at com.qtpselenium.core.ddf.testcases.DummyTestB.testB(DummyTestB.java:12)
at java.base/jdk.internal.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at java.base/jdk.internal.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62)
at java.base/jdk.internal.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
at java.base/java.lang.reflect.Method.invoke(Method.java:564)
at org.testng.internal.MethodInvocationHelper.invokeMethod(MethodInvocationHelper.java:85)
at org.testng.internal.Invoker.invokeMethod(Invoker.java:639)
at org.testng.internal.Invoker.invokeTestMethod(Invoker.java:821)
at org.testng.internal.Invoker.invokeTestMethods(Invoker.java:1131)
at org.testng.internal.TestMethodWorker.invokeTestMethods(TestMethodWorker.java:124)
at org.testng.internal.TestMethodWorker.run(TestMethodWorker.java:108)
at org.testng.TestRunner.privateRun(TestRunner.java:773)
at org.testng.TestRunner.run(TestRunner.java:623)
at org.testng.SuiteRunner.runTest(SuiteRunner.java:357)
at org.testng.SuiteRunner.runSequentially(SuiteRunner.java:352)
at org.testng.SuiteRunner.privateRun(SuiteRunner.java:310)
at org.testng.SuiteRunner.run(SuiteRunner.java:259)
at org.testng.SuiteRunnerWorker.runSuite(SuiteRunnerWorker.java:52)
at org.testng.SuiteRunnerWorker.run(SuiteRunnerWorker.java:86)
at org.testng.TestNG.runSuitesSequentially(TestNG.java:1185)
at org.testng.TestNG.runSuitesLocally(TestNG.java:1110)
at org.testng.TestNG.run(TestNG.java:1018)
at org.testng.remote.AbstractRemoteTestNG.run(AbstractRemoteTestNG.java:115)
at org.testng.remote.RemoteTestNG.initAndRun(RemoteTestNG.java:251)
at org.testng.remote.RemoteTestNG.main(RemoteTestNG.java:77)


===============================================
Default test
Tests run: 1, Failures: 1, Skips: 0
===============================================


===============================================
Default suite
Total tests run: 1, Failures: 1, Skips: 0
===============================================

[TestNG] Time taken by [FailedReporter passed=0 failed=0 skipped=0]: 57 ms
[TestNG] Time taken by org.testng.reporters.EmailableReporter2@6c7a164b: 22 ms
[TestNG] Time taken by org.testng.reporters.SuiteHTMLReporter@68746f22: 57 ms
[TestNG] Time taken by org.testng.reporters.JUnitReportReporter@7283d3eb: 11 ms
[TestNG] Time taken by org.testng.reporters.jq.Main@a8ef162: 71 ms
[TestNG] Time taken by org.testng.reporters.XMLReporter@376a0d86: 5 ms

Source Code:

BaseTest.java

package com.qtpselenium.core.ddf.base;

import org.openqa.selenium.WebDriver;
import org.openqa.selenium.chrome.ChromeDriver;
import org.openqa.selenium.firefox.FirefoxDriver;
import org.openqa.selenium.ie.InternetExplorerDriver;

public class BaseTest {
public WebDriver driver;

public void openBrowser(String bType) {
if(bType.equals("Mozilla"))
driver=new FirefoxDriver();
else if(bType.equals("Chrome")) {
System.setProperty("webdriver.chrome.driver", "C:\\Libs\\chromedriver.exe");
driver=new ChromeDriver();
}
else if(bType.equals("IE")) {
System.setProperty("webdriver.chrome.driver", "C:\\Libs\\IEDriverServer.exe");
driver=new InternetExplorerDriver();
}
}

public void openBrowser() {

}

public void navigate() {

}

public void click() {

}

public void type() {

}

/**************************Validation*********************************/

public boolean verifyTitle() {
return false;
}

public boolean isElementPresent() {
return false;
}

public boolean verifyText() {
return false;
}

/*************************Reporting**************************/
//Report the logs that just passed
public void reportPass(String msg) {

}

public void reportFail(String msg) {

}

public void takeScreenshot() {

}

}

 

DummyTestB.java

package com.qtpselenium.core.ddf.testcases;

import org.testng.annotations.Test;

import com.qtpselenium.core.ddf.base.BaseTest;

public class DummyTestB extends BaseTest{

@Test
public void testB() {

openBrowser("IE");
navigate();
click();
type();
verifyTitle();
reportFail("title does not match");

}

}

testng.xml

<suite name="SuiteName">


<test name="TestA" allow-return-values="true">
<classes>
<class name="com.qtpselenium.core.ddf.testcases.DummyTestA" />
</classes>
</test>

<test name="TestB" allow-return-values="true">
<classes>
<class name="com.qtpselenium.core.ddf.testcases.DummyTestB" />
</classes>
</test>

<test name="TestC" allow-return-values="true">
<classes>
<class name="com.qtpselenium.core.ddf.testcases.DummyTestC" />
</classes>
</test>




</suite>

 


A
Ashish Replied on 04/11/2020

java.lang.NoSuchMethodError: 'void com.google.common.base.Preconditions.checkArgument(boolean, java.lang.String, int)'

 

I guess you have not added all the selenium jars


C
Cheong Kah Seng Replied on 04/11/2020

But I have run the mvn compile, mvn elipse:eclipse based on the following pom.xml, is dependency <groupId>org.seleniumhq.selenium</groupId> considered as selenium?: 

The following attachment is my my project, sincerely hope that our dearest instructor can help to solve my question so that I can proceed to the following part of the video (I'm still stuck at second video now). Thanks in advance :)

 

<?xml version="1.0" encoding="UTF-8"?>

<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
<modelVersion>4.0.0</modelVersion>

<groupId>com.qtpselenium.core.ddf</groupId>
<artifactId>Data_Driven_Core_Framework</artifactId>
<version>1.0-SNAPSHOT</version>
<packaging>jar</packaging>

<name>Data_Driven_Core_Framework</name>
<!-- FIXME change it to the project's website -->
<url>http://maven.apache.org</url>

<properties>
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
<maven.compiler.source>1.7</maven.compiler.source>
<maven.compiler.target>1.7</maven.compiler.target>
</properties>

<dependencies>
<!-- POI -->
<dependency>
<groupId>org.apache.poi</groupId>
<artifactId>poi</artifactId>
<version>3.6</version>
</dependency>
<dependency>
<groupId>org.apache.poi</groupId>
<artifactId>poi-ooxml</artifactId>
<version>3.6</version>
</dependency>
<dependency>
<groupId>org.apache.poi</groupId>
<artifactId>poi-ooxml-schemas</artifactId>
<version>3.6</version>
</dependency>
<dependency>
<groupId>dom4j</groupId>
<artifactId>dom4j</artifactId>
<version>1.1</version>
</dependency>
<dependency>
<groupId>org.apache.xmlbeans</groupId>
<artifactId>xmlbeans</artifactId>
<version>2.3.0</version>
</dependency>
<dependency>
<groupId>org.seleniumhq.selenium</groupId>
<artifactId>selenium-java</artifactId>
<version>3.141.0</version>
</dependency>
<dependency>
<groupId>com.relevantcodes</groupId>
<artifactId>extentreports</artifactId>
<version>2.40.1</version>
</dependency>
<!-- Testng -->
<dependency>
<groupId>org.testng</groupId>
<artifactId>testng</artifactId>
<version>6.9.6</version>
<scope>test</scope>
</dependency>


<dependency>
<groupId>org.apache.maven.surefire</groupId>
<artifactId>surefire</artifactId>
<version>2.18.1</version>
<type>pom</type>
</dependency>
<!-- Appium -->

<dependency>
<groupId>io.appium</groupId>
<artifactId>java-client</artifactId>
<version>3.3.0</version>
</dependency>


<dependency>
<groupId>com.google.code.gson</groupId>
<artifactId>gson</artifactId>
<version>2.2.4</version>
</dependency>
<dependency>
<groupId>org.apache.httpcomponents</groupId>
<artifactId>httpclient</artifactId>
<version>4.3.3</version>
</dependency>
<dependency>
<groupId>com.google.guava</groupId>
<artifactId>guava</artifactId>
<version>17.0</version>
</dependency>
<dependency>
<groupId>cglib</groupId>
<artifactId>cglib</artifactId>
<version>3.1</version>
</dependency>
<dependency>
<groupId>commons-validator</groupId>
<artifactId>commons-validator</artifactId>
<version>1.4.1</version>
</dependency>
<dependency>
<groupId>javax.mail</groupId>
<artifactId>mail</artifactId>
<version>1.4</version>
</dependency>

</dependencies>
</project>

 


A
Ashish Replied on 04/11/2020

As I can understand that your browser is not getting launched and you get this error.

This can happen because of 2 reasons

1) You dont have all jars

2) Your version of driver exe is not compaitble with the browser version. I would request you to watch the webdriver videos once.

 


C
Cheong Kah Seng Replied on 04/11/2020

After I adding all the jar file to the Java Build Path, This error occur when I am trying to run testng.xml

 

[RemoteTestNG] detected TestNG version 6.9.6
WARNING: An illegal reflective access operation has occurred
WARNING: Illegal reflective access by org.testng.xml.XMLParser (file:/C:/Users/Cheong%20Kah%20Seng/.m2/repository/org/testng/testng/6.9.6/testng-6.9.6.jar) to constructor com.sun.org.apache.xerces.internal.jaxp.SAXParserFactoryImpl()
WARNING: Please consider reporting this to the maintainers of org.testng.xml.XMLParser
WARNING: Use --illegal-access=warn to enable warnings of further illegal reflective access operations
WARNING: All illegal access operations will be denied in a future release
org.testng.TestNGException:
Cannot instantiate class com.qtpselenium.core.ddf.testcases.DummyTestA
at org.testng.internal.ObjectFactoryImpl.newInstance(ObjectFactoryImpl.java:38)
at org.testng.internal.ClassHelper.createInstance1(ClassHelper.java:382)
at org.testng.internal.ClassHelper.createInstance(ClassHelper.java:295)
at org.testng.internal.ClassImpl.getDefaultInstance(ClassImpl.java:117)
at org.testng.internal.ClassImpl.getInstances(ClassImpl.java:183)
at org.testng.internal.TestNGClassFinder.<init>(TestNGClassFinder.java:128)
at org.testng.TestRunner.initMethods(TestRunner.java:415)
at org.testng.TestRunner.init(TestRunner.java:241)
at org.testng.TestRunner.init(TestRunner.java:211)
at org.testng.TestRunner.<init>(TestRunner.java:165)
at org.testng.remote.support.RemoteTestNG6_5$1.newTestRunner(RemoteTestNG6_5.java:27)
at org.testng.remote.support.RemoteTestNG6_5$DelegatingTestRunnerFactory.newTestRunner(RemoteTestNG6_5.java:63)
at org.testng.SuiteRunner$ProxyTestRunnerFactory.newTestRunner(SuiteRunner.java:584)
at org.testng.SuiteRunner.init(SuiteRunner.java:159)
at org.testng.SuiteRunner.<init>(SuiteRunner.java:114)
at org.testng.TestNG.createSuiteRunner(TestNG.java:1260)
at org.testng.TestNG.createSuiteRunners(TestNG.java:1247)
at org.testng.TestNG.runSuitesLocally(TestNG.java:1101)
at org.testng.TestNG.run(TestNG.java:1018)
at org.testng.remote.AbstractRemoteTestNG.run(AbstractRemoteTestNG.java:115)
at org.testng.remote.RemoteTestNG.initAndRun(RemoteTestNG.java:251)
at org.testng.remote.RemoteTestNG.main(RemoteTestNG.java:77)
Caused by: java.lang.reflect.InvocationTargetException
at java.base/jdk.internal.reflect.NativeConstructorAccessorImpl.newInstance0(Native Method)
at java.base/jdk.internal.reflect.NativeConstructorAccessorImpl.newInstance(NativeConstructorAccessorImpl.java:62)
at java.base/jdk.internal.reflect.DelegatingConstructorAccessorImpl.newInstance(DelegatingConstructorAccessorImpl.java:45)
at java.base/java.lang.reflect.Constructor.newInstanceWithCaller(Constructor.java:500)
at java.base/java.lang.reflect.Constructor.newInstance(Constructor.java:481)
at org.testng.internal.ObjectFactoryImpl.newInstance(ObjectFactoryImpl.java:29)
... 21 more
Caused by: java.lang.Error: Unresolved compilation problems:
The package org.openqa.selenium is accessible from more than one module: <unnamed>, org.seleniumhq.selenium.api
The package org.openqa.selenium.chrome is accessible from more than one module: <unnamed>, org.seleniumhq.selenium.chrome_driver
The package org.openqa.selenium.firefox is accessible from more than one module: <unnamed>, org.seleniumhq.selenium.firefox_driver
The package org.openqa.selenium.ie is accessible from more than one module: <unnamed>, org.seleniumhq.selenium.ie_driver
WebDriver cannot be resolved to a type
WebDriver cannot be resolved to a type
FirefoxDriver cannot be resolved to a type
WebDriver cannot be resolved to a type
ChromeDriver cannot be resolved to a type
WebDriver cannot be resolved to a type
InternetExplorerDriver cannot be resolved to a type
WebDriver cannot be resolved to a type
WebDriver cannot be resolved to a type

at com.qtpselenium.core.ddf.base.BaseTest.<init>(BaseTest.java:5)
at com.qtpselenium.core.ddf.testcases.DummyTestA.<init>(DummyTestA.java:8)
... 27 more


C
Cheong Kah Seng Replied on 04/11/2020

Update: this problem has been solved


Related Posts