How to use edge method of SeleniumRake Package

Best Selenium code snippet using SeleniumRake.edge

Rakefile

Source:Rakefile Github

copy

Full Screen

...115 //java/client/src/org/openqa/selenium/json:json.publish116 //java/client/src/org/openqa/selenium/ie:ie.publish117 //java/client/src/org/openqa/selenium/firefox/xpi:xpi.publish118 //java/client/src/org/openqa/selenium/firefox:firefox.publish119 //java/client/src/org/openqa/selenium/edge:edge.publish120 //java/client/src/org/openqa/selenium/devtools/v89:v89.publish121 //java/client/src/org/openqa/selenium/devtools/v88:v88.publish122 //java/client/src/org/openqa/selenium/devtools/v87:v87.publish123 //java/client/src/org/openqa/selenium/devtools/v86:v86.publish124 //java/client/src/org/openqa/selenium/devtools/v85:v85.publish125 //java/client/src/org/openqa/selenium/devtools:devtools.publish126 //java/client/src/org/openqa/selenium/chromium:chromium.publish127 //java/client/src/org/openqa/selenium/chrome:chrome.publish128 //java/client/src/org/openqa/selenium:core.publish129 //java/client/src/org/openqa/selenium:client-combined.publish130]131132# Notice that because we're using rake, anything you can do in a normal rake133# build can also be done here. For example, here we set the default task134task default: [:grid]135136task all: [137 :"selenium-java",138 '//java/client/test/org/openqa/selenium/environment:webserver'139]140task all_zip: [:'prep-release-zip']141task tests: [142 '//java/client/test/org/openqa/selenium/htmlunit:htmlunit',143 '//java/client/test/org/openqa/selenium/firefox:test-synthesized',144 '//java/client/test/org/openqa/selenium/ie:ie',145 '//java/client/test/org/openqa/selenium/chrome:chrome',146 '//java/client/test/org/openqa/selenium/edge:edge',147 '//java/client/test/org/openqa/selenium/opera:opera',148 '//java/client/test/org/openqa/selenium/support:small-tests',149 '//java/client/test/org/openqa/selenium/support:large-tests',150 '//java/client/test/org/openqa/selenium/remote:small-tests',151 '//java/server/test/org/openqa/selenium/remote/server/log:test',152 '//java/server/test/org/openqa/selenium/remote/server:small-tests'153]154task chrome: ['//java/client/src/org/openqa/selenium/chrome']155task grid: [:'selenium-server-standalone']156task ie: ['//java/client/src/org/openqa/selenium/ie']157task firefox: ['//java/client/src/org/openqa/selenium/firefox']158task remote: %i[remote_server remote_client]159task remote_client: ['//java/client/src/org/openqa/selenium/remote']160task remote_server: ['//java/server/src/org/openqa/selenium/remote/server']161task safari: ['//java/client/src/org/openqa/selenium/safari']162task selenium: ['//java/client/src/org/openqa/selenium:core']163task support: [164 '//java/client/src/org/openqa/selenium/lift',165 '//java/client/src/org/openqa/selenium/support'166]167168desc 'Build the standalone server'169task 'selenium-server-standalone' => '//java/server/src/org/openqa/selenium/grid:executable-grid'170171task test_javascript: [172 '//javascript/atoms:test-chrome:run',173 '//javascript/webdriver:test-chrome:run',174 '//javascript/selenium-atoms:test-chrome:run',175 '//javascript/selenium-core:test-chrome:run'176]177task test_chrome: ['//java/client/test/org/openqa/selenium/chrome:chrome:run']178task test_edge: ['//java/client/test/org/openqa/selenium/edge:edge:run']179task test_chrome_atoms: [180 '//javascript/atoms:test-chrome:run',181 '//javascript/chrome-driver:test-chrome:run',182 '//javascript/webdriver:test-chrome:run'183]184task test_htmlunit: [185 '//java/client/test/org/openqa/selenium/htmlunit:htmlunit:run'186]187task test_grid: [188 '//java/server/test/org/openqa/grid/common:common:run',189 '//java/server/test/org/openqa/grid:grid:run',190 '//java/server/test/org/openqa/grid/e2e:e2e:run',191 '//java/client/test/org/openqa/selenium/remote:remote-driver-grid-tests:run'192]193task test_ie: [194 '//cpp/iedriverserver:win32',195 '//cpp/iedriverserver:x64',196 '//java/client/test/org/openqa/selenium/ie:ie:run'197]198task test_jobbie: [:test_ie]199task test_firefox: ['//java/client/test/org/openqa/selenium/firefox:marionette:run']200task test_opera: ['//java/client/test/org/openqa/selenium/opera:opera:run']201task test_remote_server: [202 '//java/server/test/org/openqa/selenium/remote/server:small-tests:run',203 '//java/server/test/org/openqa/selenium/remote/server/log:test:run'204]205task test_remote: [206 '//java/client/test/org/openqa/selenium/json:small-tests:run',207 '//java/client/test/org/openqa/selenium/remote:common-tests:run',208 '//java/client/test/org/openqa/selenium/remote:client-tests:run',209 '//java/client/test/org/openqa/selenium/remote:remote-driver-tests:run',210 :test_remote_server211]212task test_safari: ['//java/client/test/org/openqa/selenium/safari:safari:run']213task test_support: [214 '//java/client/test/org/openqa/selenium/lift:lift:run',215 '//java/client/test/org/openqa/selenium/support:small-tests:run',216 '//java/client/test/org/openqa/selenium/support:large-tests:run'217]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' ...

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