• Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Liutauras Vilda
  • Ron McLeod
  • Jeanne Boyarsky
  • Paul Clapham
Sheriffs:
  • Junilu Lacar
  • Tim Cooke
Saloon Keepers:
  • Carey Brown
  • Stephan van Hulst
  • Tim Holloway
  • Peter Rooke
  • Himai Minh
Bartenders:
  • Piet Souris
  • Mikalai Zaikin

NetBeans 8.2: Selenium testing cannot find ChromOption()

 
Ranch Hand
Posts: 183
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Hi,
I am trying to run the following code provided by Sauce lab:


I am getting the error "cannot find symbol ChromeOptions". I am getting error on all the following lines:



I have included the client-combined-3.14.0.jar

Some body please guide me.

Zulfi.
 
Saloon Keeper
Posts: 10167
81
Eclipse IDE Firefox Browser MySQL Database VI Editor Java Windows
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
You are not importing ChromeOptions.

Can you post the command line that you're using to compile?
 
Zulfi Khan
Ranch Hand
Posts: 183
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Hi,
Thanks for your response. I have imported ChromeOptions()


but still I am getting red bubble on ChromeOptions() method in my program. I am not using command line option. The site gave a command line javac command but that was too old. So I think it should work with NetBeans 8.2. I saw a tutorial for Ellipse.

I am using NetBeans8.2 & I am working windows 10.

Zulfi.
 
Sheriff
Posts: 7125
184
Eclipse IDE Postgres Database VI Editor Chrome Java Ubuntu
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Have you added the jar(s) to the compile-time libraries?

What does NetBeans display when you hover over the red bubble?
 
Zulfi Khan
Ranch Hand
Posts: 183
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Hi
Thanks for your response. I gave you wrong infomation. I am not getting any error on ChromeOptions() but now its giving error on the next statement". Its giving error on CapabilityType i.e cannot find symbol variable CapabilityType.

I have added two imports but they are not working.

I am attaching a picture. I have added the jar file: client-combined-3.14.0.jar.

Please guide me.

Zulfi.
cannot-find-symbol-capability-type.jpg
[Thumbnail for cannot-find-symbol-capability-type.jpg]
 
Zulfi Khan
Ranch Hand
Posts: 183
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Hi,
I have got following imports:

 
Marshal
Posts: 27675
89
Eclipse IDE Firefox Browser MySQL Database
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
You're making progress! Just keep importing the types which are giving you those errors.
 
Zulfi Khan
Ranch Hand
Posts: 183
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Hi,
I am still getting unknow symbol error for CapabilityType in the following statement:

options.setCapability(CapabilityType.PLATFORM_NAME, Platform.WINDOWS);
options.setCapability(CapabilityType.UNEXPECTED_ALERT_BEHAVIOUR, UnexpectedAlertBehaviour.ACCEPT);
options.setCapability(CapabilityType.ACCEPT_SSL_CERTS, true);

Somebody please guide me.

Zulfi.
 
Knute Snortum
Sheriff
Posts: 7125
184
Eclipse IDE Postgres Database VI Editor Chrome Java Ubuntu
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
It's still a matter of you importing the correct class or static value.
You've imported CapabilityType.PLATFORM_NAME.  Have you imported Platform.WINDOWS?
You've imported CapabilityType.UNEXPECTED_ALERT_BEHAVIOUR.  Have you imported UnexpectedAlertBehaviour.ACCEPT?
Have you imported CapabilityType.ACCEPT_SSL_CERTS?
 
Zulfi Khan
Ranch Hand
Posts: 183
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Hi,
Thanks for your response. I am still getting the same errors. I have imported following libraries:


The three lines on which I am getting syntax errors are:



It says unknown variable 'CapabiltyType'

Somebody please guide me.

Zulfi.

 
Paul Clapham
Marshal
Posts: 27675
89
Eclipse IDE Firefox Browser MySQL Database
  • Likes 1
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator


You imported PLATFORM_NAME via this line. So you only have to call it PLATFORM_NAME in your code.
 
Zulfi Khan
Ranch Hand
Posts: 183
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Hi,
Thanks. I have removed the syntax errors:



but now its giving me exception error:


Exception in thread "main" java.lang.NoClassDefFoundError: okhttp3/ConnectionPool
at org.openqa.selenium.remote.internal.OkHttpClient$Factory.<init>(OkHttpClient.java:118)
at org.openqa.selenium.remote.internal.OkHttpClient$Factory.<init>(OkHttpClient.java:123)
at org.openqa.selenium.remote.http.HttpClient$Factory.createDefault(HttpClient.java:59)
at org.openqa.selenium.remote.HttpCommandExecutor.<clinit>(HttpCommandExecutor.java:47)
at org.openqa.selenium.remote.RemoteWebDriver.<init>(RemoteWebDriver.java:143)
at samplesaucetest.SampleSauceTest.main(SampleSauceTest.java:46)
Caused by: java.lang.ClassNotFoundException: okhttp3.ConnectionPool
at java.net.URLClassLoader.findClass(URLClassLoader.java:381)
at java.lang.ClassLoader.loadClass(ClassLoader.java:424)
at sun.misc.Launcher$AppClassLoader.loadClass(Launcher.java:331)
at java.lang.ClassLoader.loadClass(ClassLoader.java:357)
... 6 more
C:\Users\HP\AppData\Local\NetBeans\Cache\8.2\executor-snippets\run.xml:53: Java returned: 1
BUILD FAILED (total time: 1 second)







I have found this problem at:

webpage

One good suggestion is to use jar files. So I am trying them & give me version after including jars.

Thanks.
Zulfi.
 
Zulfi Khan
Ranch Hand
Posts: 183
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Hi,

I have solved that exception error but now I am getting another error:



Exception in thread "main" java.lang.NoClassDefFoundError: com/google/common/collect/ImmutableMap
at org.openqa.selenium.remote.HttpCommandExecutor.<init>(HttpCommandExecutor.java:59)
at org.openqa.selenium.remote.RemoteWebDriver.<init>(RemoteWebDriver.java:143)
at samplesaucetest.SampleSauceTest.main(SampleSauceTest.java:46)
Caused by: java.lang.ClassNotFoundException: com.google.common.collect.ImmutableMap
at java.net.URLClassLoader.findClass(URLClassLoader.java:381)
at java.lang.ClassLoader.loadClass(ClassLoader.java:424)
at sun.misc.Launcher$AppClassLoader.loadClass(Launcher.java:331)
at java.lang.ClassLoader.loadClass(ClassLoader.java:357)
... 3 more
C:\Users\HP\AppData\Local\NetBeans\Cache\8.2\executor-snippets\run.xml:53: Java returned: 1
BUILD FAILED (total time: 1 second)





Following link says that there are 47 jar files used for Selenium proj but I cant find them. I want to get a single jar
file for that. github link downloads a file which is not a jar file

webpage
Some body please guide me about one single jar file so that I dont have to use dozens of them.

Zulfi.
 
Knute Snortum
Sheriff
Posts: 7125
184
Eclipse IDE Postgres Database VI Editor Chrome Java Ubuntu
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
I don't know where you got the idea that there is one jar for all of Selenium.  But you only need to add the Jar files to your project that you are using.  In Netbeans open the project, right-click on the Libraries icon, and select Add JAR/Folder.

Also I want to make sure you are clear on the relationship between Jar file, imports and Classes.

* A Jar file contains one or more compiled classes.  You must tell the IDE where to find it unless it is included as standard Java (in the JDK).  You can see all the Jars included with the JDK in the Libraries folder in the Projects view.
* To use a class in your source code, use an import statement.  The only exception is the java.lang package which is imported for you.  You can also write the full path to the class, but you usually don't have to do that.

So with a third-party software package such as Selenium, start with the class you want to use -- for instance, ChromeOptions.  Find out what Jar file ChromeOptions is in.  You can use an Internet search like Selenium jar file for ChromeOptions to discover this information.  It turns out that org.openqa.selenium.chrome.ChromeOptions.class is in the selenium-chrome-driver Jar.  Download that jar (noting version and platform).  Then add this line to your code at the top:
Now when you write:
... the Java compiler will know where to look.  Do this for all the third-party classes you are using.  Since a Jar file usually contains more than one class, you do not have to download and add all Jar files.
 
Zulfi Khan
Ranch Hand
Posts: 183
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Hi,
Please guide me which jar I have to remove or its okay. I cant figure out whether I have to add jar or remove any one.


run:
Exception in thread "main" java.lang.NoSuchMethodError: com.google.common.collect.ImmutableList.copyOf(Ljava/util/Collection;)Lcom/google/common/collect/ImmutableList;
at org.openqa.selenium.chrome.ChromeOptions.asMap(ChromeOptions.java:279)
at org.openqa.selenium.remote.NewSessionPayload.create(NewSessionPayload.java:93)
at org.openqa.selenium.remote.ProtocolHandshake.createSession(ProtocolHandshake.java:67)
at org.openqa.selenium.remote.HttpCommandExecutor.execute(HttpCommandExecutor.java:136)
at org.openqa.selenium.remote.RemoteWebDriver.execute(RemoteWebDriver.java:548)
at org.openqa.selenium.remote.RemoteWebDriver.startSession(RemoteWebDriver.java:212)
at org.openqa.selenium.remote.RemoteWebDriver.<init>(RemoteWebDriver.java:130)
at org.openqa.selenium.remote.RemoteWebDriver.<init>(RemoteWebDriver.java:143)
at samplesaucetest.SampleSauceTest.main(SampleSauceTest.java:49)
C:\Users\HP\AppData\Local\NetBeans\Cache\8.2\executor-snippets\run.xml:53: Java returned: 1
BUILD FAILED (total time: 1 second)




Zulfi.
Which-jars-to-remove-or-add.jpg
[Thumbnail for Which-jars-to-remove-or-add.jpg]
 
Knute Snortum
Sheriff
Posts: 7125
184
Eclipse IDE Postgres Database VI Editor Chrome Java Ubuntu
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Error reports can be daunting, but here's what to look for.

In the first line you will see the error class, in this case "java.lang.NoSuchMethodError."  That should tell you something right there.  You're using a method that does not exist.  But what method?  Look a little further and you'll see "com.google.common.collect.ImmutableList.copyOf(Ljava/util/Collection;)."  So it looks like there is no method copyOf(Collection) in the class ImmutableList.  So, do you have com.google.common.collect.ImmutableList imported?  In the screenshot you attached, it looks like this import is commented out.  I'd uncomment it.  Also, make sure you have the correct jarfile for this method.

It's not so important for this particular situation, but you can find the line that the error occurred on by looking for the first line that has your package and class name in it.  In this case it's "at samplesaucetest.SampleSauceTest.main(SampleSauceTest.java:49)." So you know that it was line 49 in the class SampleSauceTest where the error occurred.
 
reply
    Bookmark Topic Watch Topic
  • New Topic