Package net.mindengine.galen.components.mocks.driver

Source Code of net.mindengine.galen.components.mocks.driver.MockedDriverElement

/*******************************************************************************
* Copyright 2014 Ivan Shubin http://mindengine.net
*
* 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 net.mindengine.galen.components.mocks.driver;

import org.openqa.selenium.By;
import org.openqa.selenium.Dimension;
import org.openqa.selenium.Point;
import org.openqa.selenium.WebElement;

import java.util.List;

public class MockedDriverElement implements WebElement {
    private final MockedPageItem item;

    public MockedDriverElement(MockedPageItem item) {
        this.item = item;
    }

    @Override
    public void click() {

    }

    @Override
    public void submit() {

    }

    @Override
    public void sendKeys(CharSequence... charSequences) {

    }

    @Override
    public void clear() {

    }

    @Override
    public String getTagName() {
        return "div";
    }

    @Override
    public String getAttribute(String s) {
        return null;
    }

    @Override
    public boolean isSelected() {
        return false;
    }

    @Override
    public boolean isEnabled() {
        return true;
    }

    @Override
    public String getText() {
        if (item.getText() != null) {
            return item.getText();
        }
        else return "";
    }

    @Override
    public List<WebElement> findElements(By by) {
        return null;
    }

    @Override
    public WebElement findElement(By by) {
        return null;
    }

    @Override
    public boolean isDisplayed() {
        return item.isVisible();
    }

    @Override
    public Point getLocation() {
        if (item.getArea() == null) {
            throw new RuntimeException("Element doesn't have area");
        }
        return new Point(item.getArea()[0], item.getArea()[1]);
    }


    @Override
    public Dimension getSize() {
        if (item.getArea() == null) {
            throw new RuntimeException("Element doesn't have area");
        }
        return new Dimension(item.getArea()[2], item.getArea()[3]);
    }

    @Override
    public String getCssValue(String s) {
        return null;
    }
}
TOP

Related Classes of net.mindengine.galen.components.mocks.driver.MockedDriverElement

TOP
Copyright © 2018 www.massapi.com. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.