Path: blob/trunk/rb/lib/selenium/webdriver/common/timeouts.rb
1865 views
# frozen_string_literal: true12# 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.1819module Selenium20module WebDriver21class Timeouts22def initialize(bridge)23@bridge = bridge24end2526#27# Gets the amount of time the driver should wait when searching for elements.28#2930def implicit_wait31Float(@bridge.timeouts['implicit']) / 100032end3334#35# Set the amount of time the driver should wait when searching for elements.36#3738def implicit_wait=(seconds)39@bridge.timeouts = {'implicit' => Integer(seconds * 1000)}40end4142#43# Gets the amount of time to wait for an asynchronous script to finish44# execution before throwing an error.45#4647def script48Float(@bridge.timeouts['script']) / 100049end50alias script_timeout script5152#53# Sets the amount of time to wait for an asynchronous script to finish54# execution before throwing an error. If the timeout is negative, then the55# script will be allowed to run indefinitely.56#5758def script=(seconds)59@bridge.timeouts = {'script' => Integer(seconds * 1000)}60end61alias script_timeout= script=6263#64# Gets the amount of time to wait for a page load to complete before throwing an error.65#6667def page_load68Float(@bridge.timeouts['pageLoad']) / 100069end7071#72# Sets the amount of time to wait for a page load to complete before throwing an error.73# If the timeout is negative, page loads can be indefinite.74#7576def page_load=(seconds)77@bridge.timeouts = {'pageLoad' => Integer(seconds * 1000)}78end79end # Timeouts80end # WebDriver81end # Selenium828384