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

holmos.webtest.element.tool.SeleniumElementExist Maven / Gradle / Ivy

There is a newer version: 1.0.2u10
Show newest version
package holmos.webtest.element.tool;

import holmos.webtest.Allocator;
import holmos.webtest.element.locator.Locator;
import holmos.webtest.element.locator.LocatorValue;
import holmos.webtest.struct.Collection;
import holmos.webtest.struct.Frame;
import holmos.webtest.struct.Page;

import java.util.ArrayList;

import com.thoughtworks.selenium.Selenium;


public class SeleniumElementExist extends WebElementExist{
	private String currentLocator;
	private ArrayListlocators=new ArrayList();
	private Selenium selenium=(Selenium) Allocator.getInstance().currentWindow.getDriver().getEngine();
	public SeleniumElementExist(LocatorValue webElement){
		super(webElement);
	}
	@Override
	public boolean isElementExistForCheckOnce(){
		LocatorValue lastNode=infoChain.getInfoNodes().get(infoChain.getInfoNodes().size()-1);
		if(lastNode instanceof Page || lastNode instanceof Frame){
			return findOneLevelElement(1);
		}else{
			return findMuiltiLevelElement(1);
		}
	}
	@Override
	public boolean isElementExist(int waitCount) {
		initComment();
		LocatorValue lastNode=infoChain.getInfoNodes().get(infoChain.getInfoNodes().size()-1);
		if(lastNode instanceof Page || lastNode instanceof Frame){
			return findOneLevelElement(waitCount);
		}else{
			return findMuiltiLevelElement(waitCount);
		}
	}

	private boolean findMuiltiLevelElement(int waitCount) {
		for(int i=0;i1;startLevel--){
			if(infoChain.getInfoNodes().get(startLevel) instanceof Frame){
				//找到Frame层级,跳到下一层
				startLevel++;
				break;
			}
		}
		infoChain.addNode(webElement);
		getAllLocaors(startLevel,"");
		for(int i=0;i
            


© 2015 - 2024 Weber Informatics LLC | Privacy Policy