Best Selenium code snippet using Selenium.WebDriver.release
Rakefile
Source:Rakefile
...726def version727 `svn info | grep Revision | awk -F: '{print $2}' | tr -d '[:space:]' | tr -d '\n'`728end729730task :remote_release => [:remote] do731 mkdir_p "build/dist/remote_client", :verbose => false732733 cp 'remote/build/webdriver-remote-client.jar', 'build/dist/remote_client'734 cp 'remote/build/webdriver-remote-common.jar', 'build/dist/remote_client'735 cp 'common/build/webdriver-common.jar', 'build/dist/remote_client'736737 cp Dir.glob('remote/common/lib/runtime/*.jar'), 'build/dist/remote_client'738 cp Dir.glob('remote/client/lib/runtime/*.jar'), 'build/dist/remote_client'739 cp 'third_party/java/google-collect-1.0.jar', 'build/dist/remote_client'740741 sh "cd build/dist && zip -r webdriver-remote-client-#{version}.zip remote_client/*"742 rm_rf "build/dist/remote_client", :verbose => false743744 mkdir_p "build/dist/remote_server", :verbose => false745746 cp 'remote/build/webdriver-remote-server.jar', 'build/dist/remote_server'747 cp 'remote/build/webdriver-remote-common.jar', 'build/dist/remote_server'748 cp 'common/build/webdriver-common.jar', 'build/dist/remote_server'749750 cp Dir.glob('remote/common/lib/runtime/*.jar'), 'build/dist/remote_server'751 cp Dir.glob('remote/server/lib/runtime/*.jar'), 'build/dist/remote_server'752 cp 'third_party/java/google-collect-1.0.jar', 'build/dist/remote_server'753754 rm Dir.glob('build/dist/remote_server/servlet*.jar')755756 sh "cd build/dist && zip -r webdriver-remote-server-#{version}.zip remote_server/*"757 rm_rf "build/dist/remote_server", :verbose => false758end759760java_uberjar(:name => "selenium-java",761 :deps => [762 :chrome,763 :htmlunit,764 :ie,765 :firefox,766 :remote_client,767 :selenium,768 :support769 ],770 :no_libs => true)771772task :release => [:'all_zip', :'selenium-server-standalone', :'selenium-server_zip'] do773 cp "build/selenium-server-standalone.jar", "build/selenium-server-standalone-#{version}.jar"774 cp "build/selenium-java.zip", "build/selenium-java-#{version}.zip"775 cp "build/selenium-server.zip", "build/selenium-server-#{version}.zip"776end777778task :'selenium-java_zip' do779 temp = "build/selenium-java_zip"780 mkdir_p temp781 sh "cd #{temp} && jar xf ../selenium-java.zip", :verbose => false782 rm_f "build/selenium-java.zip"783 Dir["#{temp}/webdriver-*.jar"].each { |file| rm_rf file }784 mv "#{temp}/selenium-java.jar", "#{temp}/selenium-java-#{version}.jar"785 sh "cd #{temp} && jar cMf ../selenium-java.zip *", :verbose => false786end
...
action_builder.rb
Source:action_builder.rb
...28 }29 @actions = []30 end31 #32 # Performs a modifier key press. Does not release33 # the modifier key - subsequent interactions may assume it's kept pressed.34 # Note that the modifier key is never released implicitly - either35 # #key_up(key) or #send_keys(:null) must be called to release the modifier.36 #37 # Equivalent to:38 # driver.action.click(element).send_keys(key)39 # # or40 # driver.action.click.send_keys(key)41 #42 # @example Press a key43 #44 # driver.action.key_down(:control).perform45 #46 # @example Press a key on an element47 #48 # el = driver.find_element(:id, "some_id")49 # driver.action.key_down(el, :shift).perform50 #51 # @param [:shift, :alt, :control, :command, :meta] The key to press.52 # @param [Selenium::WebDriver::Element] element An optional element53 # @raise [ArgumentError] if the given key is not a modifier54 # @return [ActionBuilder] A self reference.55 #56 def key_down(*args)57 if args.first.kind_of? Element58 @actions << [:mouse, :click, [args.shift]]59 end60 @actions << [:keyboard, :press, args]61 self62 end63 #64 # Performs a modifier key release.65 # Releasing a non-depressed modifier key will yield undefined behaviour.66 #67 # @example Release a key68 #69 # driver.action.key_up(:shift).perform70 #71 # @example Release a key from an element72 #73 # el = driver.find_element(:id, "some_id")74 # driver.action.key_up(el, :alt).perform75 #76 # @param [:shift, :alt, :control, :command, :meta] The modifier key to release.77 # @param [Selenium::WebDriver::Element] element An optional element78 # @raise [ArgumentError] if the given key is not a modifier key79 # @return [ActionBuilder] A self reference.80 #81 def key_up(*args)82 if args.first.kind_of? Element83 @actions << [:mouse, :click, [args.shift]]84 end85 @actions << [:keyboard, :release, args]86 self87 end88 #89 # Sends keys to the active element. This differs from calling90 # Element#send_keys(keys) on the active element in two ways:91 #92 # * The modifier keys included in this call are not released.93 # * There is no attempt to re-focus the element - so send_keys(:tab) for switching elements should work.94 #95 # @example Send the text "help" to an element96 #97 # el = driver.find_element(:id, "some_id")98 # driver.action.send_keys(el, "help").perform99 #100 # @example Send the text "help" to the currently focused element101 #102 # driver.action.send_keys("help").perform103 #104 # @param [Selenium::WebDriver::Element] element An optional element105 # @param [String] keys The keys to be sent.106 # @return [ActionBuilder] A self reference.107 #108 def send_keys(*args)109 if args.first.kind_of? Element110 @actions << [:mouse, :click, [args.shift]]111 end112 @actions << [:keyboard, :send_keys, args]113 self114 end115 #116 # Clicks (without releasing) in the middle of the given element. This is117 # equivalent to:118 #119 # driver.action.move_to(element).click_and_hold120 #121 # @example Clicking and holding on some element122 #123 # el = driver.find_element(:id, "some_id")124 # driver.action.click_and_hold(el).perform125 #126 # @param [Selenium::WebDriver::Element] element the element to move to and click.127 # @return [ActionBuilder] A self reference.128 #129 def click_and_hold(element = nil)130 @actions << [:mouse, :down, [element]]131 self132 end133 #134 # Releases the depressed left mouse button at the current mouse location.135 #136 # @example Releasing an element after clicking and holding it137 #138 # el = driver.find_element(:id, "some_id")139 # driver.action.click_and_hold(el).release.perform140 #141 # @return [ActionBuilder] A self reference.142 #143 def release(element = nil)144 @actions << [:mouse, :up, [element]]145 self146 end147 #148 # Clicks in the middle of the given element. Equivalent to:149 #150 # driver.action.move_to(element).click151 #152 # When no element is passed, the current mouse position will be clicked.153 #154 # @example Clicking on an element155 #156 # el = driver.find_element(:id, "some_id")157 # driver.action.click(el).perform158 #159 # @example Clicking at the current mouse position160 #161 # driver.action.click.perform162 #163 # @param [Selenium::WebDriver::Element] element An optional element to click.164 # @return [ActionBuilder] A self reference.165 #166 def click(element = nil)167 @actions << [:mouse, :click, [element]]168 self169 end170 #171 # Performs a double-click at middle of the given element. Equivalent to:172 #173 # driver.action.move_to(element).double_click174 #175 # @example Double click an element176 #177 # el = driver.find_element(:id, "some_id")178 # driver.action.double_click(el).perform179 #180 # @param [Selenium::WebDriver::Element] element An optional element to move to.181 # @return [ActionBuilder] A self reference.182 #183 def double_click(element = nil)184 @actions << [:mouse, :double_click, [element]]185 self186 end187 #188 # Moves the mouse to the middle of the given element. The element is scrolled into189 # view and its location is calculated using getBoundingClientRect. Then the190 # mouse is moved to optional offset coordinates from the element.191 #192 # Note that when using offsets, both coordinates need to be passed.193 #194 # @example Scroll element into view and move the mouse to it195 #196 # el = driver.find_element(:id, "some_id")197 # driver.action.move_to(el).perform198 #199 # @example200 #201 # el = driver.find_element(:id, "some_id")202 # driver.action.move_to(el, 100, 100).perform203 #204 # @param [Selenium::WebDriver::Element] element to move to.205 # @param [Integer] right_by Optional offset from the top-left corner. A negative value means206 # coordinates right from the element.207 # @param [Integer] down_by Optional offset from the top-left corner. A negative value means208 # coordinates above the element.209 # @return [ActionBuilder] A self reference.210 #211 def move_to(element, right_by = nil, down_by = nil)212 if right_by && down_by213 @actions << [:mouse, :move_to, [element, right_by, down_by]]214 else215 @actions << [:mouse, :move_to, [element]]216 end217 self218 end219 #220 # Moves the mouse from its current position (or 0,0) by the given offset.221 # If the coordinates provided are outside the viewport (the mouse will222 # end up outside the browser window) then the viewport is scrolled to223 # match.224 #225 # @example Move the mouse to a certain offset from its current position226 #227 # driver.action.move_by(100, 100).perform228 #229 # @param [Integer] right_by horizontal offset. A negative value means moving the230 # mouse left.231 # @param [Integer] down_by vertical offset. A negative value means moving the mouse232 # up.233 # @return [ActionBuilder] A self reference.234 # @raise [MoveTargetOutOfBoundsError] if the provided offset is outside235 # the document's boundaries.236 #237 def move_by(right_by, down_by)238 @actions << [:mouse, :move_by, [right_by, down_by]]239 self240 end241 #242 # Performs a context-click at middle of the given element. First performs243 # a move_to to the location of the element.244 #245 # @example Context-click at middle of given element246 #247 # el = driver.find_element(:id, "some_id")248 # driver.action.context_click(el).perform249 #250 # @param [Selenium::WebDriver::Element] element An element to context click.251 # @return [ActionBuilder] A self reference.252 #253 def context_click(element = nil)254 @actions << [:mouse, :context_click, [element]]255 self256 end257 #258 # A convenience method that performs click-and-hold at the location of the259 # source element, moves to the location of the target element, then260 # releases the mouse.261 #262 # @example Drag and drop one element onto another263 #264 # el1 = driver.find_element(:id, "some_id1")265 # el2 = driver.find_element(:id, "some_id2")266 # driver.action.drag_and_drop(el1, el2).perform267 #268 # @param [Selenium::WebDriver::Element] source element to emulate button down at.269 # @param [Selenium::WebDriver::Element] target element to move to and release the270 # mouse at.271 # @return [ActionBuilder] A self reference.272 #273 def drag_and_drop(source, target)274 click_and_hold source275 move_to target276 release target277 self278 end279 #280 # A convenience method that performs click-and-hold at the location of281 # the source element, moves by a given offset, then releases the mouse.282 #283 # @example Drag and drop an element by offset284 #285 # el = driver.find_element(:id, "some_id1")286 # driver.action.drag_and_drop_by(el, 100, 100).perform287 #288 # @param [Selenium::WebDriver::Element] source Element to emulate button down at.289 # @param [Integer] right_by horizontal move offset.290 # @param [Integer] down_by vertical move offset.291 # @param [Selenium::WebDriver::Element] target Element to move to and release the292 # mouse at.293 # @return [ActionBuilder] A self reference.294 #295 def drag_and_drop_by(source, right_by, down_by)296 click_and_hold source297 move_by right_by, down_by298 release299 self300 end301 #302 # Executes the actions added to the builder.303 #304 def perform305 @actions.each { |receiver, method, args|306 @devices.fetch(receiver).__send__(method, *args)307 }308 nil309 end310 end # ActionBuilder311 end # WebDriver312end # Selenium...
selenium-webdriver-0.0.17.gemspec
Source:selenium-webdriver-0.0.17.gemspec
1# -*- encoding: utf-8 -*-2Gem::Specification.new do |s|3 s.name = %q{selenium-webdriver}4 s.version = "0.0.17"5 s.required_rubygems_version = Gem::Requirement.new(">= 0") if s.respond_to? :required_rubygems_version=6 s.authors = ["Jari Bakken"]7 s.date = %q{2010-02-11}8 s.description = %q{WebDriver is a tool for writing automated tests of websites. It aims to mimic the behaviour of a real user, and as such interacts with the HTML of the application.}9 s.email = %q{jari.bakken@gmail.com}10 s.files = ["COPYING", "common/src/rb/lib/selenium/webdriver/bridge_helper.rb", "common/src/rb/lib/selenium/webdriver/child_process.rb", "common/src/rb/lib/selenium/webdriver/core_ext/dir.rb", "common/src/rb/lib/selenium/webdriver/driver.rb", "common/src/rb/lib/selenium/webdriver/driver_extensions/takes_screenshot.rb", "common/src/rb/lib/selenium/webdriver/element.rb", "common/src/rb/lib/selenium/webdriver/error.rb", "common/src/rb/lib/selenium/webdriver/find.rb", "common/src/rb/lib/selenium/webdriver/keys.rb", "common/src/rb/lib/selenium/webdriver/navigation.rb", "common/src/rb/lib/selenium/webdriver/options.rb", "common/src/rb/lib/selenium/webdriver/platform.rb", "common/src/rb/lib/selenium/webdriver/target_locator.rb", "common/src/rb/lib/selenium/webdriver.rb", "common/src/rb/lib/selenium-webdriver.rb", "common/src/rb/README", "common/src/js/abstractcommandprocessor.js", "common/src/js/asserts.js", "common/src/js/by.js", "common/src/js/command.js", "common/src/js/context.js", "common/src/js/core/Blank.html", "common/src/js/core/icons/all.png", "common/src/js/core/icons/continue.png", "common/src/js/core/icons/continue_disabled.png", "common/src/js/core/icons/pause.png", "common/src/js/core/icons/pause_disabled.png", "common/src/js/core/icons/selected.png", "common/src/js/core/icons/step.png", "common/src/js/core/icons/step_disabled.png", "common/src/js/core/InjectedRemoteRunner.html", "common/src/js/core/lib/cssQuery/cssQuery-p.js", "common/src/js/core/lib/cssQuery/src/cssQuery-level2.js", "common/src/js/core/lib/cssQuery/src/cssQuery-level3.js", "common/src/js/core/lib/cssQuery/src/cssQuery-standard.js", "common/src/js/core/lib/cssQuery/src/cssQuery.js", "common/src/js/core/lib/prototype.js", "common/src/js/core/lib/scriptaculous/builder.js", "common/src/js/core/lib/scriptaculous/controls.js", "common/src/js/core/lib/scriptaculous/dragdrop.js", "common/src/js/core/lib/scriptaculous/effects.js", "common/src/js/core/lib/scriptaculous/scriptaculous.js", "common/src/js/core/lib/scriptaculous/slider.js", "common/src/js/core/lib/scriptaculous/unittest.js", "common/src/js/core/lib/snapsie.js", "common/src/js/core/RemoteRunner.html", "common/src/js/core/scripts/find_matching_child.js", "common/src/js/core/scripts/htmlutils.js", "common/src/js/core/scripts/injection.html", "common/src/js/core/scripts/selenium-api.js", "common/src/js/core/scripts/selenium-browserbot.js", "common/src/js/core/scripts/selenium-browserdetect.js", "common/src/js/core/scripts/selenium-commandhandlers.js", "common/src/js/core/scripts/selenium-executionloop.js", "common/src/js/core/scripts/selenium-logging.js", "common/src/js/core/scripts/selenium-remoterunner.js", "common/src/js/core/scripts/selenium-testrunner.js", "common/src/js/core/scripts/selenium-version.js", "common/src/js/core/scripts/ui-doc.html", "common/src/js/core/scripts/ui-element.js", "common/src/js/core/scripts/ui-map-sample.js", "common/src/js/core/scripts/user-extensions.js", "common/src/js/core/scripts/user-extensions.js.sample", "common/src/js/core/scripts/xmlextras.js", "common/src/js/core/selenium-logo.png", "common/src/js/core/selenium-test.css", "common/src/js/core/selenium.css", "common/src/js/core/SeleniumLog.html", "common/src/js/core/TestPrompt.html", "common/src/js/core/TestRunner-splash.html", "common/src/js/core/TestRunner.html", "common/src/js/core/xpath/dom.js", "common/src/js/core/xpath/javascript-xpath-0.1.11.js", "common/src/js/core/xpath/util.js", "common/src/js/core/xpath/xmltoken.js", "common/src/js/core/xpath/xpath.js", "common/src/js/extension/dommessenger.js", "common/src/js/extension/README", "common/src/js/factory.js", "common/src/js/future.js", "common/src/js/jsunit/app/css/jsUnitStyle.css", "common/src/js/jsunit/app/css/readme", "common/src/js/jsunit/app/emptyPage.html", "common/src/js/jsunit/app/jsUnitCore.js", "common/src/js/jsunit/app/jsUnitMockTimeout.js", "common/src/js/jsunit/app/jsUnitTestManager.js", "common/src/js/jsunit/app/jsUnitTestSuite.js", "common/src/js/jsunit/app/jsUnitTracer.js", "common/src/js/jsunit/app/jsUnitVersionCheck.js", "common/src/js/jsunit/app/main-counts-errors.html", "common/src/js/jsunit/app/main-counts-failures.html", "common/src/js/jsunit/app/main-counts-runs.html", "common/src/js/jsunit/app/main-counts.html", "common/src/js/jsunit/app/main-data.html", "common/src/js/jsunit/app/main-errors.html", "common/src/js/jsunit/app/main-frame.html", "common/src/js/jsunit/app/main-loader.html", "common/src/js/jsunit/app/main-progress.html", "common/src/js/jsunit/app/main-results.html", "common/src/js/jsunit/app/main-status.html", "common/src/js/jsunit/app/testContainer.html", "common/src/js/jsunit/app/testContainerController.html", "common/src/js/jsunit/app/xbDebug.js", "common/src/js/jsunit/changelog.txt", "common/src/js/jsunit/css/jsUnitStyle.css", "common/src/js/jsunit/images/green.gif", "common/src/js/jsunit/images/logo_jsunit.gif", "common/src/js/jsunit/images/powerby-transparent.gif", "common/src/js/jsunit/images/red.gif", "common/src/js/jsunit/licenses/gpl-2.txt", "common/src/js/jsunit/licenses/index.html", "common/src/js/jsunit/licenses/JDOM_license.txt", "common/src/js/jsunit/licenses/Jetty_license.html", "common/src/js/jsunit/licenses/lgpl-2.1.txt", "common/src/js/jsunit/licenses/MPL-1.1.txt", "common/src/js/jsunit/licenses/mpl-tri-license-c.txt", "common/src/js/jsunit/licenses/mpl-tri-license-html.txt", "common/src/js/jsunit/readme.txt", "common/src/js/jsunit/testRunner.html", "common/src/js/jsunit/version.txt", "common/src/js/jsunit.js", "common/src/js/key.js", "common/src/js/localcommandprocessor.js", "common/src/js/testcase.js", "common/src/js/timing.js", "common/src/js/webdriver.js", "common/src/js/webelement.js", "firefox/src/rb/lib/selenium/webdriver/firefox/binary.rb", "firefox/src/rb/lib/selenium/webdriver/firefox/bridge.rb", "firefox/src/rb/lib/selenium/webdriver/firefox/extension_connection.rb", "firefox/src/rb/lib/selenium/webdriver/firefox/launcher.rb", "firefox/src/rb/lib/selenium/webdriver/firefox/profile.rb", "firefox/src/rb/lib/selenium/webdriver/firefox/profiles_ini.rb", "firefox/src/rb/lib/selenium/webdriver/firefox/util.rb", "firefox/src/rb/lib/selenium/webdriver/firefox.rb", "firefox/src/extension/chrome.manifest", "firefox/src/extension/components/badCertListener.js", "firefox/src/extension/components/context.js", "firefox/src/extension/components/driver-component.js", "firefox/src/extension/components/firefoxDriver.js", "firefox/src/extension/components/json2.js", "firefox/src/extension/components/keytest.html", "firefox/src/extension/components/nsCommandProcessor.js", "firefox/src/extension/components/promptService.js", "firefox/src/extension/components/screenshooter.js", "firefox/src/extension/components/socketListener.js", "firefox/src/extension/components/utils.js", "firefox/src/extension/components/webdriverserver.js", "firefox/src/extension/components/webLoadingListener.js", "firefox/src/extension/components/wrappedElement.js", "firefox/src/extension/content/fxdriver.xul", "firefox/src/extension/content/server.js", "firefox/src/extension/idl/nsICommandProcessor.idl", "firefox/src/extension/idl/nsIResponseHandler.idl", "firefox/src/extension/install.rdf", "firefox/prebuilt/linux/Release/libwebdriver-firefox.so", "firefox/prebuilt/linux/Release/x_ignore_nofocus.so", "firefox/prebuilt/linux64/Release/libwebdriver-firefox.so", "firefox/prebuilt/linux64/Release/x_ignore_nofocus.so", "firefox/prebuilt/nsICommandProcessor.xpt", "firefox/prebuilt/nsINativeEvents.xpt", "firefox/prebuilt/nsIResponseHandler.xpt", "firefox/prebuilt/Win32/Release/webdriver-firefox.dll", "chrome/src/rb/lib/selenium/webdriver/chrome/bridge.rb", "chrome/src/rb/lib/selenium/webdriver/chrome/command_executor.rb", "chrome/src/rb/lib/selenium/webdriver/chrome/launcher.rb", "chrome/src/rb/lib/selenium/webdriver/chrome.rb", "chrome/src/extension/background.html", "chrome/src/extension/background.js", "chrome/src/extension/content_script.js", "chrome/src/extension/icons/busy.png", "chrome/src/extension/icons/free.png", "chrome/src/extension/manifest-nonwin.json", "chrome/src/extension/manifest-win.json", "chrome/src/extension/utils.js", "chrome/prebuilt/Win32/Release/npchromedriver.dll", "chrome/prebuilt/x64/Release/npchromedriver.dll", "jobbie/src/rb/lib/selenium/webdriver/ie/bridge.rb", "jobbie/src/rb/lib/selenium/webdriver/ie/lib.rb", "jobbie/src/rb/lib/selenium/webdriver/ie/util.rb", "jobbie/src/rb/lib/selenium/webdriver/ie.rb", "jobbie/prebuilt/Win32/Release/InternetExplorerDriver.dll", "jobbie/prebuilt/x64/Release/InternetExplorerDriver.dll", "remote/client/src/rb/lib/selenium/webdriver/remote/bridge.rb", "remote/client/src/rb/lib/selenium/webdriver/remote/capabilities.rb", "remote/client/src/rb/lib/selenium/webdriver/remote/commands.rb", "remote/client/src/rb/lib/selenium/webdriver/remote/default_http_client.rb", "remote/client/src/rb/lib/selenium/webdriver/remote/response.rb", "remote/client/src/rb/lib/selenium/webdriver/remote/server_error.rb", "remote/client/src/rb/lib/selenium/webdriver/remote.rb"]11 s.homepage = %q{http://selenium.googlecode.com}12 s.require_paths = ["common/src/rb/lib", "firefox/src/rb/lib", "chrome/src/rb/lib", "jobbie/src/rb/lib", "remote/client/src/rb/lib"]13 s.rubygems_version = %q{1.3.6}14 s.summary = %q{The next generation developer focused tool for automated testing of webapps}15 if s.respond_to? :specification_version then16 current_version = Gem::Specification::CURRENT_SPECIFICATION_VERSION17 s.specification_version = 318 if Gem::Version.new(Gem::RubyGemsVersion) >= Gem::Version.new('1.2.0') then19 s.add_runtime_dependency(%q<json_pure>, [">= 0"])20 s.add_runtime_dependency(%q<ffi>, [">= 0"])21 s.add_development_dependency(%q<rspec>, [">= 0"])22 s.add_development_dependency(%q<rack>, [">= 0"])23 else24 s.add_dependency(%q<json_pure>, [">= 0"])25 s.add_dependency(%q<ffi>, [">= 0"])26 s.add_dependency(%q<rspec>, [">= 0"])27 s.add_dependency(%q<rack>, [">= 0"])28 end29 else30 s.add_dependency(%q<json_pure>, [">= 0"])31 s.add_dependency(%q<ffi>, [">= 0"])32 s.add_dependency(%q<rspec>, [">= 0"])33 s.add_dependency(%q<rack>, [">= 0"])34 end35end...
chrome_node.rb
Source:chrome_node.rb
...65 return super if chromedriver_fixed_actions_key_state? || !w3c? || element.obscured?66 raise ArgumentError, 'Modifier keys are not supported while dragging in this version of Chrome.' unless drop_modifiers.empty?67 # W3C Chrome/chromedriver < 77 doesn't maintain mouse button state across actions API performs68 # https://bugs.chromium.org/p/chromedriver/issues/detail?id=298169 browser_action.release.perform70 browser_action.click_and_hold(native).move_to(element.native).release.perform71 end72 def file_errors73 @file_errors = ::Selenium::WebDriver.logger.suppress_deprecations do74 [::Selenium::WebDriver::Error::ExpectedError]75 end76 end77 def w3c?78 (defined?(Selenium::WebDriver::VERSION) && (Selenium::WebDriver::VERSION.to_f >= 4)) ||79 capabilities.is_a?(::Selenium::WebDriver::Remote::W3C::Capabilities)80 end81 def browser_version(to_float = true)82 caps = capabilities83 ver = (caps[:browser_version] || caps[:version])84 ver = ver.to_f if to_float...
action_builder_spec.rb
Source:action_builder_spec.rb
...7 let(:builder) { Selenium::WebDriver::ActionBuilder.new(mouse, keyboard) }8 it "should create all keyboard actions" do9 keyboard.should_receive(:press).with(:shift)10 keyboard.should_receive(:send_keys).with("abc")11 keyboard.should_receive(:release).with(:control)12 builder.key_down(:shift).13 send_keys("abc").14 key_up(:control).perform15 end16 it "should pass an element to keyboard actions" do17 mouse.should_receive(:click).with(element)18 keyboard.should_receive(:press).with(:shift)19 builder.key_down(element, :shift).perform20 end21 it "should allow supplying individual elements to keyboard actions" do22 element2 = Selenium::WebDriver::Element.new(bridge, 'element2')23 element3 = Selenium::WebDriver::Element.new(bridge, 'element3')24 mouse.should_receive(:click).with(element)25 keyboard.should_receive(:press).with(:shift)26 mouse.should_receive(:click).with(element2)27 keyboard.should_receive(:send_keys).with("abc")28 mouse.should_receive(:click).with(element3)29 keyboard.should_receive(:release).with(:control)30 builder.key_down(element, :shift ).31 send_keys(element2, "abc").32 key_up(element3, :control).perform33 end34 it "should create all mouse actions" do35 mouse.should_receive(:down).with(element)36 mouse.should_receive(:up).with(element)37 mouse.should_receive(:click).with(element)38 mouse.should_receive(:double_click).with(element)39 mouse.should_receive(:move_to).with(element)40 mouse.should_receive(:context_click).with(element)41 builder.click_and_hold(element).42 release(element).43 click(element).44 double_click(element).45 move_to(element).46 context_click(element).perform47 end48 it "should drag and drop" do49 source = element50 target = Selenium::WebDriver::Element.new(bridge, 'element2')51 mouse.should_receive(:down).with(source)52 mouse.should_receive(:move_to).with(target)53 mouse.should_receive(:up)54 builder.drag_and_drop(source, target).perform55 end56 it "should drag and drop with offsets" do57 source = element58 mouse.should_receive(:down).with(source)59 mouse.should_receive(:move_by).with(-300, 400)60 mouse.should_receive(:up)61 builder.drag_and_drop_by(source, -300, 400).perform62 end63 it "can move the mouse by coordinates" do64 mouse.should_receive(:down).with(element)65 mouse.should_receive(:move_by).with(-300, 400)66 mouse.should_receive(:up)67 builder.click_and_hold(element).68 move_by(-300, 400).69 release.perform70 end71 it 'can click, hold and release at the current location' do72 mouse.should_receive(:down).with(nil)73 mouse.should_receive(:up)74 builder.click_and_hold.release.perform75 end76end...
release
Using AI Code Generation
1driver.find_element(:name, 'q').send_keys "Selenium WebDriver"2driver.find_element(:name, 'btnG').click3driver.find_element(:name, 'q').send_keys "Selenium WebDriver"4driver.find_element(:name, 'btnG').click5driver.find_element(:name, 'q').send_keys "Selenium WebDriver"6driver.find_element(:name, 'btnG').click
release
Using AI Code Generation
1driver.find_element(:name, 'q').send_keys "Selenium"2driver.find_element(:name, 'btnG').click3driver.find_element(:name, 'q').send_keys "Selenium"4driver.find_element(:name, 'btnG').click5driver.find_element(:name, 'q').send_keys "Selenium"6driver.find_element(:name, 'btnG').click7driver.find_element(:name, 'q').send_keys "Selenium"8driver.find_element(:name, 'btnG').click9driver.find_element(:name, 'q').send_keys "Selenium"10driver.find_element(:name, 'btnG').click11driver.find_element(:name, 'q').send_keys "Selenium"12driver.find_element(:name, 'btnG').click13driver.find_element(:name, 'q').send_keys "Selenium"14driver.find_element(:name, 'btnG').click
release
Using AI Code Generation
1driver.find_element(:name, 'q').send_keys "selenium"2driver.find_element(:name, 'btnG').click3driver.find_element(:name, 'q').send_keys "selenium"4driver.find_element(:name, 'btnG').click
release
Using AI Code Generation
1driver.find_element(:name, 'q').send_keys "Selenium WebDriver"2driver.find_element(:name, 'q').send_keys :enter3driver.find_element(:link_text, 'Selenium WebDriver').click
release
Using AI Code Generation
1driver.find_element(:name, 'q').send_keys "Selenium WebDriver"2driver.find_element(:name, 'btnG').click3driver.find_element(:name, 'q').send_keys "Selenium WebDriver"4driver.find_element(:name, 'btnG').click5driver.find_element(:name, 'q').send_keys "Selenium WebDriver"6driver.find_element(:name, 'btnG').click7driver.find_element(:name, 'q').send_keys "Selenium WebDriver"8driver.find_element(:name, 'btnG').click9driver.find_element(:name, 'q').send_keys "Selenium WebDriver"10driver.find_element(:name, 'btnG').click11driver.find_element(:name, 'q').send_keys "Selenium WebDriver"12driver.find_element(:name, 'btnG').click
release
Using AI Code Generation
1driver.find_element(:name, 'q').send_keys "Selenium"2driver.find_element(:name, 'btnG').click3driver.find_element(:name, 'q').send_keys "Selenium"4driver.find_element(:name, 'btnG').click5driver.find_element(:name, 'q').send_keys "Selenium"6driver.find_element(:name, 'btnG').click7driver.find_element(:name, 'q').send_keys "Selenium"8driver.find_element(:name, 'btnG').click9driver.find_element(:name, 'q').send_keys "Selenium"10driver.find_element(:name, 'btnG').click11driver.find_element(:name, 'q').send_keys "Selenium"12driver.find_element(:name, 'btnG').click
release
Using AI Code Generation
1driver.find_element(:name, 'q').send_keys "selenium"2driver.find_element(:name, 'btnG').click3driver.find_element(:name, 'q').send_keys "selenium"4driver.find_element(:name, 'btnG').click
release
Using AI Code Generation
1driver.find_element(:name, 'q').send_keys "Selenium"2driver.find_element(:name, 'btnG').click3driver.find_element(:name, 'q').send_keys "Selenium"4driver.find_element(:name, 'btnG').click5driver.find_element(:name, 'q').send_keys "Selenium"6driver.find_element(:name, 'btnG').click7driver.find_element(:name, 'q').send_keys "Selenium"8driver.find_element(:name, 'btnG').click9driver.find_element(:name, 'q').send_keys "Selenium"10driver.find_element(:name, 'btnG').click11driver.find_element(:name, 'q').send_keys "Selenium"12driver.find_element(:name, 'btnG').click
release
Using AI Code Generation
1driver.find_element(:name, 'q').send_keys "Selenium WebDriver"2driver.find_element(:name, 'q').send_keys :enter3driver.find_element(:link_text, 'Selenium WebDriver').click
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.
You could also refer to video tutorials over LambdaTest YouTube channel to get step by step demonstration from industry experts.
Get 100 minutes of automation test minutes FREE!!