io.appium.java_client.touch.WaitOptions Maven / Gradle / Ivy
Go to download
Show more of this group Show more artifacts with this name
Show all versions of java-client Show documentation
Show all versions of java-client Show documentation
Java client for Appium Mobile Webdriver
/*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* See the NOTICE file distributed with this work for additional
* information regarding copyright ownership.
* 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 io.appium.java_client.touch;
import java.time.Duration;
import java.util.Map;
import static com.google.common.base.Preconditions.checkArgument;
import static java.time.Duration.ofMillis;
import static java.util.Objects.requireNonNull;
public class WaitOptions extends ActionOptions {
protected Duration duration = ofMillis(0);
/**
* Creates and instance of {@link WaitOptions}.
*
* @param duration is the duration of the waiting.
* @return a built option.
*/
public static WaitOptions waitOptions(Duration duration) {
return new WaitOptions().withDuration(duration);
}
/**
* Set the wait duration.
*
* @param duration the value to set.
* Time resolution unit is 1 ms.
* @return this instance for chaining.
*/
public WaitOptions withDuration(Duration duration) {
requireNonNull(duration);
checkArgument(duration.toMillis() >= 0,
"Duration value should be greater or equal to zero");
this.duration = duration;
return this;
}
@Override
protected void verify() {
//there is nothing to check
}
@Override
public Map build() {
final Map result = super.build();
result.put("ms", duration.toMillis());
return result;
}
}
© 2015 - 2024 Weber Informatics LLC | Privacy Policy