/java/client/src/org/openqa/selenium/internal/selenesedriver/ExecuteAsyncScript.java
Java | 47 lines | 22 code | 10 blank | 15 comment | 0 complexity | 1b7aedc57f46e3cbfc2171d759335a12 MD5 | raw file
Possible License(s): LGPL-2.1, MPL-2.0-no-copyleft-exception, AGPL-1.0, MIT, Apache-2.0, BSD-3-Clause, GPL-2.0
- /*
- Copyright 2007-2010 Selenium committers
- Licensed under the Apache License, Version 2.0 (the "License");
- you may not use this file except in compliance with the License.
- You may obtain a copy of the License at
- http://www.apache.org/licenses/LICENSE-2.0
- Unless required by applicable law or agreed to in writing, software
- distributed under the License is distributed on an "AS IS" BASIS,
- WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- See the License for the specific language governing permissions and
- limitations under the License.
- */
- package org.openqa.selenium.internal.selenesedriver;
- import com.thoughtworks.selenium.Selenium;
- import java.util.List;
- import java.util.Map;
- public class ExecuteAsyncScript implements SeleneseFunction<Object> {
- private long timeoutMillis = 0;
- public Object apply(Selenium selenium, Map<String, ?> parameters) {
- String script = (String) parameters.get("script");
- @SuppressWarnings({"unchecked"})
- List<Object> args = (List<Object>) parameters.get("args");
- return new ScriptExecutor(selenium)
- .executeAsyncScript(script, args, timeoutMillis);
- }
- public SeleneseFunction<Object> setScriptTimeout() {
- return new SeleneseFunction<Object>() {
- public Object apply(Selenium selenium, Map<String, ?> args) {
- ExecuteAsyncScript.this.timeoutMillis = ((Number) args.get("ms")).longValue();
- return null;
- }
- };
- }
- }