Best Selenium code snippet using Selenium.WebDriver.shutdown_supported
service_manager.rb
Source:service_manager.rb
...36 @executable_path = config.executable_path37 @host = Platform.localhost38 @port = config.port39 @extra_args = config.extra_args40 @shutdown_supported = config.shutdown_supported41 raise Error::WebDriverError, "invalid port: #{@port}" if @port < 142 end43 def start44 raise "already started: #{uri.inspect} #{@executable_path.inspect}" if process_running?45 Platform.exit_hook(&method(:stop)) # make sure we don't leave the server running46 socket_lock.locked do47 find_free_port48 start_process49 connect_until_stable50 end51 end52 def stop53 return unless @shutdown_supported54 stop_server55 @process.poll_for_exit STOP_TIMEOUT56 rescue ChildProcess::TimeoutError57 nil # noop58 ensure59 stop_process60 end61 def uri62 @uri ||= URI.parse("http://#{@host}:#{@port}")63 end64 private65 def build_process(*command)66 WebDriver.logger.debug("Executing Process #{command}")67 @process = ChildProcess.build(*command)...
service.rb
Source:service.rb
1# frozen_string_literal: true2# Licensed to the Software Freedom Conservancy (SFC) under one3# or more contributor license agreements. See the NOTICE file4# distributed with this work for additional information5# regarding copyright ownership. The SFC licenses this file6# to you under the Apache License, Version 2.0 (the7# "License"); you may not use this file except in compliance8# with the License. You may obtain a copy of the License at9#10# http://www.apache.org/licenses/LICENSE-2.011#12# Unless required by applicable law or agreed to in writing,13# software distributed under the License is distributed on an14# "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY15# KIND, either express or implied. See the License for the16# specific language governing permissions and limitations17# under the License.18require 'selenium/webdriver/chrome/service'19module Selenium20 module WebDriver21 module Edge22 class Service < Selenium::WebDriver::Chrome::Service23 DEFAULT_PORT = 951524 EXECUTABLE = 'msedgedriver'25 MISSING_TEXT = <<~ERROR26 Unable to find msedgedriver. Please download the server from27 https://developer.microsoft.com/en-us/microsoft-edge/tools/webdriver/ and place it somewhere on your PATH.28 ERROR29 SHUTDOWN_SUPPORTED = true30 end # Service31 end # Edge32 end # WebDriver33end # Selenium...
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!!