Setup Java project

62 views
Skip to first unread message

Luís Soares

unread,
Nov 9, 2022, 1:26:43 AM11/9/22
to Selenium Users
Hey

I'm having trouble setting up Java's Selenium on my Mac.

I've never used or even heard about Bazel which is making things harder.
I did exactly what was in the instructions:

  1. brew install bazelisk
  2. bazel build java/...
I get this:
ERROR: /Users/lsoares/Documents/selenium/java/out/test/selenium/org/openqa/selenium/firefox/BUILD.bazel:99:10: in _copy_file rule //java/out/test/selenium/org/openqa/selenium/firefox:webextensions_selenium_example: target '//common/extensions:webextensions-selenium-example.xpi' is not visible from target '//java/out/test/selenium/org/openqa/selenium/firefox:webextensions_selenium_example'. Check the visibility declaration of the former target if you think the dependency is legitimate. To set the visibility of that source file target, use the exports_files() function
ERROR: /Users/lsoares/Documents/selenium/java/out/test/selenium/org/openqa/selenium/firefox/BUILD.bazel:99:10: Analysis of target '//java/out/test/selenium/org/openqa/selenium/firefox:webextensions_selenium_example' failed
ERROR: Analysis of target '//java/out/test/selenium/org/openqa/selenium/firefox:webextensions_selenium_example' failed; build aborted:
INFO: Elapsed time: 0.109s
INFO: 0 processes.
FAILED: Build did NOT complete successfully (0 packages loaded, 0 targets configured)


Thank you so much! I'm excited to contribute to Selenium, but this is draining my energy 😅

⇜Krishnan Mahadevan⇝

unread,
Nov 9, 2022, 5:11:36 AM11/9/22
to seleniu...@googlegroups.com
Are you referring to the instructions from here: https://github.com/SeleniumHQ/selenium/wiki/Build-Instructions ?

I just now attempted to run the same command on the latest commit in "trunk" and it builds fine for me (Am on Mac as well).

Thanks & Regards
Krishnan Mahadevan

"All the desirable things in life are either illegal, expensive, fattening or in love with someone else!"
My Scribblings @ http://wakened-cognition.blogspot.com/
My Technical Scribblings @ https://rationaleemotions.com/


--
You received this message because you are subscribed to the Google Groups "Selenium Users" group.
To unsubscribe from this group and stop receiving emails from it, send an email to selenium-user...@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/selenium-users/8d27a5c4-6071-453e-9bb4-3cec28f1bd11n%40googlegroups.com.

Luís Soares

unread,
Nov 10, 2022, 1:56:02 AM11/10/22
to Selenium Users
I was referring to: https://github.com/lsoares/selenium#java
Now I'm confused. what are those instructions?
Trying them anyway on a fresh project.

bazel build grid
looks good.
but IntelliJ is still full of errors: https://ibb.co/5vSt28T


then I did:
➜  selenium git:(trunk) ✗ java -jar bazel-bin/java/server/src/org/openqa/selenium/grid/selenium_server_deploy.jar standalone
Error: Unable to access jarfile bazel-bin/java/server/src/org/openqa/selenium/grid/selenium_server_deploy.jar



also tried:
➜  selenium git:(trunk) ✗ bazel test java/client/test/org/openqa/selenium/chrome
ERROR: Skipping 'java/client/test/org/openqa/selenium/chrome': no such target '//java:client/test/org/openqa/selenium/chrome': target 'client/test/org/openqa/selenium/chrome' not declared in package 'java' defined by /Users/lsoares/Documents/selenium/java/BUILD.bazel
ERROR: no such target '//java:client/test/org/openqa/selenium/chrome': target 'client/test/org/openqa/selenium/chrome' not declared in package 'java' defined by /Users/lsoares/Documents/selenium/java/BUILD.bazel
INFO: Elapsed time: 0.161s
INFO: 0 processes.
FAILED: Build did NOT complete successfully (0 packages loaded)
FAILED: Build did NOT complete successfully (0 packages loaded)



so I'm stuck there. thank you

⇜Krishnan Mahadevan⇝

unread,
Nov 10, 2022, 2:10:37 AM11/10/22
to seleniu...@googlegroups.com
Let's see if I can walk you through on what worked for me.

Install the Bazel IntelliJ plugin

image.png


This is how my bazel settings look like in IntelliJ (To setup buildifier run brew install buildifier)

image.png

Now click Import Bazel project button

image.png

Choose the home directory for bazel in the next screen (The directory where the WORKSPACE file exists)

image.png

In the next screen choose Generate from BUILD file and choose "java/BUILD.bazel"

image.png

The last screen which contains the create button should look like this

image.png

Now IntelliJ is going to spend sometime in setting up bazel build etc.,

Just to ensure that all is well, trigger a bazel sync explicitly by choosing Bazel > Sync > Sync Project with BUILD files.

That should do it. You should now be ready to go with working with the selenium codebase within IntelliJ.

I have never had to run any commands from the command line using the bazel binary for working on the codebase in IntelliJ.

Hope that helps!

Thanks & Regards
Krishnan Mahadevan

"All the desirable things in life are either illegal, expensive, fattening or in love with someone else!"
My Scribblings @ http://wakened-cognition.blogspot.com/
My Technical Scribblings @ https://rationaleemotions.com/

Luís Soares

unread,
Nov 10, 2022, 8:53:14 AM11/10/22
to Selenium Users
omg it's fixed! thank you for the previous tutorial! this needs to be somewhere in a readme file. most people use Gradle/Maven not Bazel.
(I assumed I needed to run command-line commands but the Bazel plugin is enough it seems)
thank you again

Reply all
Reply to author
Forward
0 new messages