All Downloads are FREE. Search and download functionalities are using the official Maven repository.

com.tidal.wave.commands.RightClick Maven / Gradle / Ivy

There is a newer version: 1.3.1
Show newest version
package com.tidal.wave.commands;

import com.tidal.wave.command.Command;
import com.tidal.wave.command.CommandAction;
import com.tidal.wave.command.CommandContext;
import com.tidal.wave.command.Commands;
import com.tidal.wave.counter.TimeCounter;
import com.tidal.wave.exceptions.CommandExceptions;
import com.tidal.wave.supplier.ObjectSupplier;
import com.tidal.wave.webelement.Element;
import org.openqa.selenium.WebElement;
import org.openqa.selenium.interactions.Actions;
import org.openqa.selenium.remote.RemoteWebElement;

import java.util.Map;
import java.util.function.Supplier;

public final class RightClick extends CommandAction implements Command {

    final Supplier, Supplier>> ignoredExceptions = this::ignoredEx;
    private final Element webElement = (Element) ObjectSupplier.instanceOf(Element.class);
    private final TimeCounter timeCounter = new TimeCounter();

    private boolean visibility;
    private boolean isMultiple;

    @Override
    public void contextSetter(CommandContext context) {
        this.isMultiple = context.isMultiple();
        this.visibility = context.getVisibility();
        this.locators = context.getLocators();
    }

    @Override
    public Map, Supplier> ignoredEx() {
        return CommandExceptions.TypeOf.stale();
    }

    public void rightClickAction() {
        WebElement element = webElement.getElement(locators, visibility, isMultiple);
        new Actions(((RemoteWebElement) element).getWrappedDriver()).contextClick(element).perform();
    }

    public void rightClick() {
        timeCounter.restart();
        super.execute(Commands.ClickCommands.RIGHT_CLICK.toString(), ignoredExceptions, timeCounter);
    }
}




© 2015 - 2025 Weber Informatics LLC | Privacy Policy