How to use windows method of SeleniumRake Package

Best Selenium code snippet using SeleniumRake.windows

Rakefile

Source:Rakefile Github

copy

Full Screen

...218219# TODO(simon): test-core should go first, but it's changing the least for now.220task test_selenium: [:'test-rc']221task 'test-rc': ['//java/client/test/com/thoughtworks/selenium:firefox-rc-test:run']222task 'test-rc': ['//java/client/test/com/thoughtworks/selenium:ie-rc-test:run'] if SeleniumRake::Checks.windows?223224task test_java_webdriver: %i[225 test_htmlunit226 test_firefox227 test_remote_server228]229230task test_java_webdriver: [:test_ie] if SeleniumRake::Checks.windows?231task test_java_webdriver: [:test_chrome] if SeleniumRake::Checks.chrome?232task test_java_webdriver: [:test_edge] if SeleniumRake::Checks.edge?233task test_java_webdriver: [:test_opera] if SeleniumRake::Checks.opera?234235task test_java: [236 '//java/client/test/org/openqa/selenium/atoms:test:run',237 :test_java_small_tests,238 :test_support,239 :test_java_webdriver,240 :test_selenium,241 'test_grid'242]243244task test_java_small_tests: [245 '//java/client/test/org/openqa/selenium:small-tests:run',246 '//java/client/test/org/openqa/selenium/json:small-tests:run',247 '//java/client/test/org/openqa/selenium/support:small-tests:run',248 '//java/client/test/org/openqa/selenium/remote:common-tests:run',249 '//java/client/test/org/openqa/selenium/remote:client-tests:run',250 '//java/server/test/org/openqa/grid/selenium/node:node:run',251 '//java/server/test/org/openqa/grid/selenium/proxy:proxy:run',252 '//java/server/test/org/openqa/selenium/remote/server:small-tests:run',253 '//java/server/test/org/openqa/selenium/remote/server/log:test:run'254]255256task test_rb: ['//rb:unit-test', :test_rb_local, :test_rb_remote]257258task test_rb_local: [259 '//rb:chrome-test',260 '//rb:firefox-test',261 ('//rb:firefox-nightly-test' if ENV['FIREFOX_NIGHTLY_BINARY']),262 ('//rb:safari-preview-test' if SeleniumRake::Checks.mac?),263 ('//rb:safari-test' if SeleniumRake::Checks.mac?),264 ('//rb:ie-test' if SeleniumRake::Checks.windows?),265 ('//rb:edge-test' unless SeleniumRake::Checks.linux?)266].compact267268task test_rb_remote: [269 '//rb:remote-chrome-test',270 '//rb:remote-firefox-test',271 ('//rb:remote-firefox-nightly-test' if ENV['FIREFOX_NIGHTLY_BINARY']),272 ('//rb:remote-safari-test' if SeleniumRake::Checks.mac?),273 # BUG - https://github.com/SeleniumHQ/selenium/issues/6791274 # ('//rb:remote-safari-preview-test' if SeleniumRake::Checks.mac?),275 ('//rb:remote-ie-test' if SeleniumRake::Checks.windows?),276 ('//rb:remote-edge-test' unless SeleniumRake::Checks.linux?)277].compact278279task test_py: [:py_prep_for_install_release, 'py:marionette_test']280task test: %i[test_javascript test_java test_rb]281task test: [:test_py] if SeleniumRake::Checks.python?282task build: %i[all firefox remote selenium tests]283284desc 'Clean build artifacts.'285task :clean do286 rm_rf 'build/'287 rm_rf 'java/client/build/'288 rm_rf 'dist/'289end290291# Create a new IEGenerator instance292ie_generator = SeleniumRake::IEGenerator.new293294# Generate a C++ Header file for mapping between magic numbers and #defines295# in the C++ code.296ie_generator.generate_type_mapping(297 name: 'ie_result_type_cpp',298 src: 'cpp/iedriver/result_types.txt',299 type: 'cpp',300 out: 'cpp/iedriver/IEReturnTypes.h'301)302303task javadocs: %i[//java/server/src/org/openqa/selenium/grid:all-javadocs] do304 rm_rf 'build/javadoc'305 mkdir_p 'build/javadoc'306307 out = Rake::Task['//java/server/src/org/openqa/selenium/grid:all-javadocs'].out308309 cmd = %{cd build/javadoc && jar xf "../../#{out}" 2>&1}310 if SeleniumRake::Checks.windows?311 cmd = cmd.gsub(/\//, '\\').gsub(/:/, ';')312 end313314315 ok = system(cmd)316 ok or raise "could not unpack javadocs"317318 File.open('build/javadoc/stylesheet.css', 'a') { |file|319 file.write(<<~EOF320 /* Custom selenium-specific styling */321 .blink {322 animation: 2s cubic-bezier(0.5, 0, 0.85, 0.85) infinite blink;323 }324325 @keyframes blink {326 50% {327 opacity: 0;328 }329 }330331 EOF332 )333 }334end335336file 'cpp/iedriver/sizzle.h' => ['//third_party/js/sizzle:sizzle:header'] do337 cp 'build/third_party/js/sizzle/sizzle.h', 'cpp/iedriver/sizzle.h'338end339340task sizzle_header: ['cpp/iedriver/sizzle.h']341342task ios_driver: [343 '//javascript/atoms/fragments:get_visible_text:ios',344 '//javascript/atoms/fragments:click:ios',345 '//javascript/atoms/fragments:back:ios',346 '//javascript/atoms/fragments:forward:ios',347 '//javascript/atoms/fragments:submit:ios',348 '//javascript/atoms/fragments:xpath:ios',349 '//javascript/atoms/fragments:xpaths:ios',350 '//javascript/atoms/fragments:type:ios',351 '//javascript/atoms/fragments:get_attribute:ios',352 '//javascript/atoms/fragments:clear:ios',353 '//javascript/atoms/fragments:is_selected:ios',354 '//javascript/atoms/fragments:is_enabled:ios',355 '//javascript/atoms/fragments:is_shown:ios',356 '//javascript/atoms/fragments:stringify:ios',357 '//javascript/atoms/fragments:link_text:ios',358 '//javascript/atoms/fragments:link_texts:ios',359 '//javascript/atoms/fragments:partial_link_text:ios',360 '//javascript/atoms/fragments:partial_link_texts:ios',361 '//javascript/atoms/fragments:get_interactable_size:ios',362 '//javascript/atoms/fragments:scroll_into_view:ios',363 '//javascript/atoms/fragments:get_effective_style:ios',364 '//javascript/atoms/fragments:get_element_size:ios',365 '//javascript/webdriver/atoms/fragments:get_location_in_view:ios'366]367368task 'prep-release-zip': [369 '//java/client/src/org/openqa/selenium:client-zip',370 '//java/server/src/org/openqa/selenium/grid:server-zip',371 '//java/server/src/org/openqa/selenium/grid:executable-grid',372 '//java/server/src/org/openqa/selenium/server/htmlrunner:selenium-runner_deploy.jar'373] do374 ["build/dist/selenium-server-#{version}.zip", "build/dist/selenium-java-#{version}.zip",375 "build/dist/selenium-server-#{version}.jar", "build/dist/selenium-html-runner-#{version}.jar"].each do |f|376 rm_f(f) if File.exists?(f)377 end378379 mkdir_p 'build/dist'380 File.delete381 cp Rake::Task['//java/server/src/org/openqa/selenium/grid:server-zip'].out, "build/dist/selenium-server-#{version}.zip", preserve: false382 chmod 0666, "build/dist/selenium-server-#{version}.zip"383 cp Rake::Task['//java/client/src/org/openqa/selenium:client-zip'].out, "build/dist/selenium-java-#{version}.zip", preserve: false384 chmod 0666, "build/dist/selenium-java-#{version}.zip"385 cp Rake::Task['//java/server/src/org/openqa/selenium/grid:executable-grid'].out, "build/dist/selenium-server-#{version}.jar", preserve: false386 chmod 0666, "build/dist/selenium-server-#{version}.jar"387 cp Rake::Task['//java/server/src/org/openqa/selenium/server/htmlrunner:selenium-runner_deploy.jar'].out, "build/dist/selenium-html-runner-#{version}.jar", preserve: false388 chmod 0666, "build/dist/selenium-html-runner-#{version}.jar"389end390391task 'release-java': %i[publish-maven push-release]392393def read_user_pass_from_m2_settings394 settings = File.read(ENV['HOME'] + '/.m2/settings.xml')395 found_section = false396 user = nil397 pass = nil398 settings.each_line do |line|399 if !found_section400 found_section = line.include? '<id>sonatype-nexus-staging</id>'401 else402 if (user.nil?) && line.include?('<username>')403 user = line.split('<username>')[1].split('</')[0]404 elsif (pass.nil?) && line.include?('<password>')405 pass = line.split('<password>')[1].split('</')[0]406 end407 end408 end409410 return [user, pass]411end412413task 'publish-maven': JAVA_RELEASE_TARGETS + %w[//java/server/src/org/openqa/selenium/server/htmlrunner:selenium-runner_deploy.jar] do414 creds = read_user_pass_from_m2_settings415 JAVA_RELEASE_TARGETS.each do |p|416 Bazel::execute('run', ['--stamp', '--define', 'maven_repo=https://oss.sonatype.org/service/local/staging/deploy/maven2', '--define', "maven_user=#{creds[0]}", '--define', "maven_password=#{creds[1]}", '--define', 'gpg_sign=true'], p)417 end418end419420task :'maven-install' do421 JAVA_RELEASE_TARGETS.each do |p|422 Bazel::execute('run', ['--stamp', '--define', "maven_repo=file://#{ENV['HOME']}/.m2/repository", '--define', 'gpg_sign=true'], p)423 end424end425426task 'push-release': [:'prep-release-zip'] do427 py = 'java -jar third_party/py/jython.jar'428 py = 'python' if SeleniumRake::Checks.python?429430 sh "#{py} third_party/py/googlestorage/publish_release.py --project_id google.com:webdriver --bucket selenium-release --acl public-read --publish_version #{google_storage_version} --publish build/dist/selenium-server-#{version}.jar --publish build/dist/selenium-java-#{version}.zip --publish build/dist/selenium-server-#{version}.jar --publish build/dist/selenium-html-runner-#{version}.jar"431end432433desc 'Build the selenium client jars'434task 'selenium-java' => '//java/client/src/org/openqa/selenium:client-combined'435436namespace :safari do437 desc 'Build the SafariDriver java client'438 task build: [439 '//java/client/src/org/openqa/selenium/safari'440 ]441end442443task :authors do444 puts 'Generating AUTHORS file'445 sh "(git log --use-mailmap --format='%aN <%aE>' ; cat .OLD_AUTHORS) | sort -uf > AUTHORS"446end447448namespace :copyright do449 task :update do450 Copyright.new.update(451 FileList['javascript/**/*.js'].exclude(452 'javascript/atoms/test/jquery.min.js',453 'javascript/jsunit/**/*.js',454 'javascript/node/selenium-webdriver/node_modules/**/*.js',455 'javascript/selenium-core/lib/**/*.js',456 'javascript/selenium-core/scripts/ui-element.js',457 'javascript/selenium-core/scripts/ui-map-sample.js',458 'javascript/selenium-core/scripts/user-extensions.js',459 'javascript/selenium-core/scripts/xmlextras.js',460 'javascript/selenium-core/xpath/**/*.js'461 )462 )463 Copyright.new(comment_characters: '#').update(FileList['py/**/*.py'])464 Copyright.new(comment_characters: '#', prefix: ["# frozen_string_literal: true\n", "\n"])465 .update(FileList['rb/**/*.rb'])466 Copyright.new.update(FileList['java/**/*.java'])467 end468end469470namespace :side do471 task atoms: [472 '//javascript/atoms/fragments:find-element'473 ] do474 # TODO: move directly to IDE's directory once the repositories are merged475 baseDir = 'build/javascript/atoms'476 mkdir_p baseDir477478 [479 Rake::Task['//javascript/atoms/fragments:find-element'].out480 ].each do |atom|481 name = File.basename(atom)482483 puts "Generating #{atom} as #{name}"484 File.open(File.join(baseDir, name), 'w') do |f|485 f << "// GENERATED CODE - DO NOT EDIT\n"486 f << 'module.exports = '487 f << IO.read(atom).strip488 f << ";\n"489 end490 end491 end492end493494namespace :jruby do495 desc 'Update jruby version'496 task :update do497 jruby_version = '9.2.8.0'498 jruby_gems = { 'inifile' => '3.0.0' }499 jar_name = "jruby-complete-#{jruby_version}.jar"500 url = "https://repo1.maven.org/maven2/org/jruby/jruby-complete/#{jruby_version}/#{jar_name}"501502 Dir.chdir('third_party/jruby') do503 puts "Downloading #{jar_name} from #{url}..."504 File.open(jar_name, 'wb') do |write_file|505 open(url, 'rb') do |read_file|506 write_file.write(read_file.read)507 end508 end509510 puts 'Installing gems...'511 jruby_gems.each do |gem_name, gem_version|512 sh 'java', '-jar', jar_name, '-S', 'gem', 'install', '-i', "./#{gem_name}", gem_name, '-v', gem_version513 sh 'jar', 'uf', jar_name, '-C', gem_name, '.'514 rm_rf gem_name515 end516517 puts 'Bumping VERSION...'518 version = `java -jar #{jar_name} -v`.split("\n").first519 File.write('VERSION', "#{version}\n")520521 mv jar_name, 'jruby-complete.jar'522 puts 'Done!'523 end524 end525end526527namespace :node do528 atom_list = %w[529 //javascript/atoms/fragments:find-elements530 //javascript/atoms/fragments:is-displayed531 //javascript/webdriver/atoms:get-attribute532 ]533534 task atoms: atom_list do535 baseDir = 'javascript/node/selenium-webdriver/lib/atoms'536 mkdir_p baseDir537538 puts 'rake outs are below'539 p rake_outs = [540 Rake::Task['//javascript/atoms/fragments:is-displayed'].out,541 Rake::Task['//javascript/webdriver/atoms:get-attribute'].out,542 Rake::Task['//javascript/atoms/fragments:find-elements'].out543 ]544545 rake_outs.each do |atom|546 puts "atom is #{atom}\n"547 name = File.basename(atom)548549 puts "Generating #{atom} as #{name}"550 File.open(File.join(baseDir, name), 'w') do |f|551 f << "// GENERATED CODE - DO NOT EDIT\n"552 f << 'module.exports = '553 f << IO.read(atom).strip554 f << ";\n"555 end556 end557 end558559 task :build do560 sh 'bazel build //javascript/node/selenium-webdriver'561 end562563 task 'dry-run': [564 'node:build'565 ] do566 sh 'bazel run javascript/node/selenium-webdriver:selenium-webdriver.pack'567 end568569 task deploy: [570 'node:build'571 ] do572 sh 'bazel run javascript/node/selenium-webdriver:selenium-webdriver.publish'573 end574575 task :docs do576 sh 'node javascript/node/gendocs.js'577 end578end579580namespace :py do581 task prep: [582 '//javascript/atoms/fragments:is-displayed',583 '//javascript/webdriver/atoms:get-attribute',584 '//third_party/js/selenium:webdriver_xpi'585 ] do586 py_home = 'py/'587 remote_py_home = py_home + 'selenium/webdriver/remote/'588 firefox_py_home = py_home + 'selenium/webdriver/firefox/'589590 if SeleniumRake::Checks.windows?591 remote_py_home = remote_py_home.gsub(/\//, '\\')592 firefox_py_home = firefox_py_home .gsub(/\//, '\\')593 end594595 cp Rake::Task['//javascript/atoms/fragments:is-displayed'].out, remote_py_home + 'isDisplayed.js', verbose: true596 cp Rake::Task['//javascript/webdriver/atoms:get-attribute'].out, remote_py_home + 'getAttribute.js', verbose: true597598 cp Rake::Task['//third_party/js/selenium:webdriver_xpi'].out, firefox_py_home, verbose: true599 cp 'third_party/js/selenium/webdriver.json', firefox_py_home + 'webdriver_prefs.json', verbose: true600 cp 'LICENSE', py_home + 'LICENSE', verbose: true601 end602603 bazel :unit do604 Bazel.execute('test', [], '//py:unit')605 end606607 task docs: :prep do608 sh 'tox -c py/tox.ini -e docs', verbose: true609 end610611 task install: :prep do612 Dir.chdir('py') do613 sh py_exe + ' setup.py install', verbose: true614 end615 end616617 %w[chrome ff marionette ie edge remote_firefox safari].each do |browser|618 browser_data = SeleniumRake::Browsers::BROWSERS[browser]619 deps = browser_data[:deps] || []620 deps += [:prep]621 driver = browser_data[:driver]622623 task "#{browser}_test" => deps do624 tox_test driver625 end626 end627end628629at_exit do630 if File.exist?('.git') && !SeleniumRake::Checks.windows?631 system 'sh', '.git-fixfiles'632 end633end ...

Full Screen

Full Screen

Automation Testing Tutorials

Learn to execute automation testing from scratch with LambdaTest Learning Hub. Right from setting up the prerequisites to run your first automation test, to following best practices and diving deeper into advanced test scenarios. LambdaTest Learning Hubs compile a list of step-by-step guides to help you be proficient with different test automation frameworks i.e. Selenium, Cypress, TestNG etc.

LambdaTest Learning Hubs:

YouTube

You could also refer to video tutorials over LambdaTest YouTube channel to get step by step demonstration from industry experts.

Try LambdaTest Now !!

Get 100 minutes of automation test minutes FREE!!

Next-Gen App & Browser Testing Cloud

Was this article helpful?

Helpful

NotHelpful