chromebrew icon indicating copy to clipboard operation
chromebrew copied to clipboard

Add Chromedriver

Open bmheenan opened this issue 8 years ago • 13 comments

Not sure if this has already been considered, but the addition of Chromedriver would be really helpful. Doesn't look like there's an easy way to get Chromedriver and its dependencies on my Chromebook

bmheenan avatar Jan 26 '17 00:01 bmheenan

The dependencies are pretty easy to setup but there are some things that complicate usage of chromedriver on a chromebook. The primary dependencies are a working openjdk, the selenium server standalone jar, and webdriver. The complicated part seems to be logging into the machine with telemetry. Try installing openjdk via crew, download the chromedriver binary and place it at /usr/local/chromedriver/chromedriver and go from there.

It expects X_AUTHORITY to be set to /home/chronos/.Xauthority. It expects X_SERVER_DISPLAY = ':0' It expects CHROMEDRIVER_EXE_PATH = '/usr/local/chromedriver/chromedriver'

See https://chromium.googlesource.com/chromiumos/third_party/autotest/+/master/client/common_lib/cros/chromedriver.py

cstrouse avatar Jan 27 '17 03:01 cstrouse

Thanks, I'll look into doing setting it up manually

bmheenan avatar Feb 06 '17 20:02 bmheenan

With Chromebrew/Linuxbrew available is it possible to setup Xvfb or it's replacement (escaping me ATM) and handle some of the dependencies?

dragon788 avatar Feb 22 '17 03:02 dragon788

@uberhacker Think that this is possible? I could work on it.

JL2210 avatar Dec 19 '18 19:12 JL2210

@cstrouse provided some good feedback on how to get started. We already have jdk8 and sellenium_server_standalone packages.

uberhacker avatar Dec 19 '18 19:12 uberhacker

There's apparently a way to support this on test images already:

https://chromedriver.chromium.org/getting-started/chromeos

https://sites.google.com/a/chromium.org/chromedriver/getting-started/chromeos

pinuke avatar Jul 15 '22 03:07 pinuke

This code search may shed some light as to how it is built and added...

https://source.chromium.org/chromiumos/chromiumos/codesearch/+/main:src/third_party/chromiumos-overlay/chromeos-base/chromeos-chrome/chromeos-chrome-105.0.5176.0_rc-r2.ebuild?q=chromedriver&ss=chromiumos%2Fchromiumos%2Fcodesearch

So far it doesn't look like anything special is done to the ChromeDriver build in the test image...

EDIT: ChromeDriver is built before this script is run, then it is added to the /usr/local/chromedriver directory... so this search result wasn't much help...

I'm gonna keep going until I can find how it is built/packaged with the test image

pinuke avatar Jul 15 '22 03:07 pinuke

Actually my prior edit to my above comment was seemingly wrong:

It looks like ChromeDriver is built using the chrome_make function from line 963

The function call is on line 1038

Chrome targets gets chromedriver appended to it on line 1027

pinuke avatar Jul 15 '22 04:07 pinuke

Here is the eclass file: https://source.chromium.org/chromiumos/chromiumos/codesearch/+/main:src/third_party/chromiumos-overlay/eclass/chromium-source.eclass?q=ENINJA&ss=chromiumos%2Fchromiumos%2Fcodesearch

All it does for chrome_make is define ENINJA, which is just the location of the ninja binary.

So, I guess the only thing left is to try is to get the ninja binary onto Chrome OS, and see if I can get it to build ChromeDriver using the arguments provided to chrome_make. Currenty, I have no idea as to what dependencies are required...

Need to powerwash CB. ChromeBrew stopped functioning at the moment :/

Note to self (usually I do this on reddit account, but it is currently suspended): if you get a "permission denied" error when installing depot_tools on chrome OS, it probably happened, because the filesystem is mounted with the noexec flag. Fix: sudo mount -o remount,rw exec ~ (provided by superuser.com)

pinuke avatar Jul 15 '22 16:07 pinuke

Best of luck!! I'm excited to see and assist with your associated pull request.

saltedcoffii avatar Jul 15 '22 17:07 saltedcoffii

This comment will be dedicated to breaking down the chrome_make call.

  • will add as I go
  • will add references to the code search for each section
  • [ ] will add TL;DR:

what does chrome_make do:

  • (nothing here yet, give me a few minutes :| internet is slow. using delta wifi aboard a jet right now...)

chrome_make function call:

chrome_make is originally called in what looks like the ebuild file that builds/ships the chromium browser on line 1038 (link to codesearch)

1038: chrome_make "${chrome_targets[@]}"

Expanding that line...

1. $chrome_targets[@]

For those who don't regularly write bash (like myself), the @ symbol just expands the array as a " "-delimeted string (it's a bash "arguments generator" similar to JavaScript's ... operator)

The array is written on line 1027 (link to codesearch):

1026: if use build_tests; then
1027:   chrome_targets+=(
1028:      "${TEST_FILES[@]}"
1029:      "${TOOLS_TELEMETRY_BIN[@]}"
1030:      chromedriver
1031:   )
1032:    if use chrome_internal; then
1033:     chrome_targets+=( libassistant_debug.so )
1034:   fi
1035: fi

Line 1026 explains the statement on the ChromeDriver Docs as to why ChromeDriver only ships with Test images

So, "${chrome_targets[@]}" should *expand into "${TEST_FILES[@]} ${TOOLS_TELEMETRY_BIN[@]} chromedriver".

(*Obviously, ${TEST_FILES[@]} ${TOOLS_TELEMETRY_BIN[@]} would also be expanded, but since I don't currently know what that evaluates to, I'll ignore it)

For now, the chrome_make call now evaluates to

chrome_make "${TEST_FILES[@]} ${TOOLS_TELEMETRY_BIN[@]} chromedriver"

2. chrome_make:

chrome_make is a function defined on line 963 (link to codesearch)

(give me another minute... I'm landing... need to store laptop... - landed. got an hour before I go enjoy my Saturday)

This is the entire function definition (omitting line numbers for now):

chrome_make() {
	local build_dir="${BUILD_OUT_SYM}/${BUILDTYPE}"

	# If ThinLTO is enabled, we may have a cache from a previous link. Due
	# to fears about lack of reproducibility, we don't allow cache reuse
	# across rebuilds. The cache is still useful for artifacts shared
	# between multiple links done by this build (e.g. tests).
	use thinlto && rm -rf "${build_dir}/thinlto-cache"

	local parallelism="$(makeopts_jobs)"
	# If goma or remoteexec is enabled, increase the number of parallel
	# run to 10 * {number of processors}. Though, if it is too large the
	# performance gets slow down, so limit by 200 heuristically.
	if use_goma || use_remoteexec; then
		local num_parallel=$(($(nproc) * 10))
		local j_limit=200
		parallelism=$((num_parallel < j_limit ? num_parallel : j_limit))
	fi
	local command=(
		"${ENINJA}"
		-j "${parallelism}"
		-C "${build_dir}"
		$(usex verbose -v "")
		-d "keeprsp"
		"$@"
	)
	# If goma is used, log the command, cwd and env vars, which will be
	# uploaded to the logging server.
	if should_upload_build_logs; then
		env --null > "${GLOG_log_dir}/ninja_env"
		pwd > "${GLOG_log_dir}/ninja_cwd"
		echo "${command[@]}" > "${GLOG_log_dir}/ninja_command"
	fi
	PATH=${PATH}:${DEPOT_TOOLS} "${command[@]}"
	local ret=$?
	if should_upload_build_logs; then
		echo "${ret}" > "${GLOG_log_dir}/ninja_exit"
		cp -p "${BUILD_OUT_SYM}/${BUILDTYPE}/.ninja_log" "${GLOG_log_dir}/ninja_log"
	fi
	[[ "${ret}" -eq 0 ]] || die

	# Still use a script to check if the orderfile is used properly, i.e.
	# Builtin_ functions are placed between the markers, etc.
	if use strict_toolchain_checks && (use orderfile_use || use orderfile_verify); then
		einfo "Verifying orderfile..."
		"${FILESDIR}/check_orderfile.py" "${build_dir}/chrome" || die
	fi
}

There is a lot of things to take note of here:

  • No definition of ENINJA
  • we get a build directory
  • it has code for Goma (google's version of distcc) and ThinLTO (a link time optimization). This may give us an idea as to how this may be compiled
  • we now know that the PATH variable has to be set for the invocation of `"{$command[@]}"
  • similarly to the chrome_targets variable, command represents a " "-delimeted string that is evaluated as a bash command

(gotta take another break, will continue most likely tomorrow)

pinuke avatar Jul 15 '22 21:07 pinuke

FYI this appears to bebased upon a Gentoo build environment... which has been extremely poorly supported for use outside of Google Corporate on chromeos devices...

Are you still working on this?

satmandu avatar Jan 26 '23 22:01 satmandu

Best of luck!! I'm excited to see and assist with your associated pull request.

I do apologize for my absence on this, but I've got college going on with a full time job. I hope you guys can pick up where I left off. I know I didn't leave much.

Are you still working on this?

I am not sure that they are. I think they were expecting me to continue to work on it. My bad. I didn't commit to finishing it, and now I've got too much on my plate to finish it out. I'm sorry.

pinuke avatar Jan 27 '23 04:01 pinuke