本文整理汇总了Java中org.openqa.selenium.Point类的典型用法代码示例。如果您正苦于以下问题:Java Point类的具体用法?Java Point怎么用?Java Point使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。
Point类属于org.openqa.selenium包,在下文中一共展示了Point类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: run
import org.openqa.selenium.Point; //导入依赖的package包/类
@Override
public void run() {
super.run();
By locator = readLocatorArgument("locator");
MobileElement element = getElement(locator);
Point point = element.getLocation();
int x = point.getX();
int y = point.getY();
int width = element.getSize().width;
int height = element.getSize().height;
Logger.trace(String.format("The element aspect is (%s,%s,%s,%s)",
x, y, width, height));
this.writeOutput("x", x);
this.writeOutput("y", y);
this.writeOutput("width", width);
this.writeOutput("height", height);
}
示例2: swipeRight
import org.openqa.selenium.Point; //导入依赖的package包/类
protected void swipeRight(MobileElement element) {
Point point = element.getLocation();
Point p = element.getCenter();
Dimension size = driver.manage().window().getSize();
int screenWidth = (int) (size.width * 0.90);
// int elementX = point.getX();
int elementX = p.getX();
int endY = 0;
int endX = element.getSize().getWidth();
// Logger.debug("Device height:" + size.getHeight() + "$$$ Device width:" + size.getWidth());
// Logger.debug("Element X:" + point.getX() + "$$$ Element Y:" + point.getY());
// Logger.debug("Element Height:" + element.getSize().height + "$$$$ Element Width:" + element.getSize().width);
// Logger.debug("end X:" + endX + "$$$$end Y:" + endY);
TouchAction action = new TouchAction((MobileDriver) driver);
//action.press(element).moveTo(endX, endY).release().perform();
action.press((int) (point.getX() + (element.getSize().getWidth() * 0.10)), element.getCenter().getY()).moveTo((int) (screenWidth - (point.getX() + (element.getSize().getWidth() * 0.10))), endY).release().perform();
}
示例3: mark
import org.openqa.selenium.Point; //导入依赖的package包/类
@Override
public void mark(WebElement ele, File file) throws IOException
{
BufferedImage bufImg = ImageIO.read(file);
try
{
WebElement webEle = (WebElement) ele;
Point loc = webEle.getLocation();
Dimension size = webEle.getSize();
Graphics2D g = bufImg.createGraphics();
g.setColor(Color.red);
g.drawRect(loc.getX(), loc.getY(), size.getWidth(), size.getHeight());
}
catch(StaleElementReferenceException se)
{
}
}
示例4: windowSetPosition
import org.openqa.selenium.Point; //导入依赖的package包/类
public void windowSetPosition() throws Throwable {
driver = new JavaDriver();
SwingUtilities.invokeAndWait(new Runnable() {
@Override public void run() {
frame.setLocationRelativeTo(null);
frame.setVisible(true);
}
});
Window window = driver.manage().window();
Point actual = window.getPosition();
AssertJUnit.assertNotNull(actual);
java.awt.Point expected = EventQueueWait.call(frame, "getLocation");
AssertJUnit.assertEquals(expected.x, actual.x);
AssertJUnit.assertEquals(expected.y, actual.y);
window.setPosition(new Point(expected.x + 10, expected.y + 10));
actual = window.getPosition();
AssertJUnit.assertEquals(expected.x + 10, actual.x);
AssertJUnit.assertEquals(expected.y + 10, actual.y);
}
示例5: getLocation
import org.openqa.selenium.Point; //导入依赖的package包/类
public void getLocation() throws Throwable {
driver = new JavaDriver();
SwingUtilities.invokeAndWait(new Runnable() {
@Override public void run() {
frame.setLocationRelativeTo(null);
frame.setVisible(true);
}
});
WebElement element1 = driver.findElement(By.name("click-me"));
Point location = element1.getLocation();
java.awt.Point p = EventQueueWait.call(button, "getLocation");
AssertJUnit.assertEquals(p.x, location.x);
AssertJUnit.assertEquals(p.y, location.y);
}
示例6: isCover
import org.openqa.selenium.Point; //导入依赖的package包/类
/**
* 判断要点击的元素是否被其它元素覆盖
*
* @param clickBy
* @param coverBy
* @return
*/
public boolean isCover(By clickBy, By coverBy) {
MobileElement clickElement = getDriver().findElement(clickBy);
MobileElement coverElement = getDriver().findElement(coverBy);
// 获取控件开始位置高度
Point clickstart = clickElement.getLocation();
int clickStartY = clickstart.y;
Point coverstart = coverElement.getLocation();
int coverStartY = coverstart.y;
// 获取控件高度
Dimension firstq = clickElement.getSize();
int height = firstq.getHeight();
// 控件中间高度是否大于底部高度
if (clickStartY + height / 2 >= coverStartY) {
return true;
}
return false;
}
示例7: isCover
import org.openqa.selenium.Point; //导入依赖的package包/类
/**
* 判断要点击的元素是否被其它元素覆盖
*
* @param clickBy
* @param coverBy
* @return
*/
public boolean isCover(By clickBy, By coverBy) {
MobileElement clickElement = getDriver().findElement(clickBy);
MobileElement coverElement = getDriver().findElement(coverBy);
// 获取控件开始位置高度
Point clickstart = clickElement.getLocation();
int clickStartY = clickstart.y;
Point coverstart = coverElement.getLocation();
int coverStartY = coverstart.y;
// 获取控件高度
Dimension firstq = clickElement.getSize();
int height = firstq.getHeight();
// 控件中间高度是否大于底部高度
if (clickStartY + height / 2 >= coverStartY) {
return true;
}
return false;
}
示例8: swipeDown
import org.openqa.selenium.Point; //导入依赖的package包/类
protected void swipeDown(MobileElement element) {
Point point = element.getLocation();
Dimension size = driver.manage().window().getSize();
int screenHeight = (int) (size.height * 0.90);
int elementY = point.getY();
int endX = 0;
int endY = ((int) screenHeight - elementY);
// Logger.debug("Device height:" + size.getHeight() + "$$$ Device width:" + size.getWidth());
// Logger.debug("Element X:" + point.getX() + "$$$ Element Y:" + point.getY());
// Logger.debug("Element Height:" + element.getSize().height + "$$$$ Element Width:" + element.getSize().width);
// Logger.debug("end X:" + endX + "$$$$end Y:" + endY);
TouchAction action = new TouchAction((MobileDriver) driver);
//action.press(element).moveTo(endX, endY).release().perform();
action.press(element.getCenter().getX(), element.getCenter().getY()).moveTo(endX, screenHeight - element.getCenter().getY()).release().perform();
}
示例9: returnElementPosition
import org.openqa.selenium.Point; //导入依赖的package包/类
protected void returnElementPosition(MobileElement element) {
Point point;
MobileElement element1;
List<MobileElement> allElements = (List<MobileElement>) element.findElements(By.xpath(".//*"));
for (int i = 0; i < allElements.size(); i++) {
element1 = allElements.get(i);
point = element1.getLocation();
int x = point.getX();
int y = point.getY();
int width = element.getSize().width;
int height = element.getSize().height;
break;
}
}
示例10: setRaidType
import org.openqa.selenium.Point; //导入依赖的package包/类
/**
* Note: raid window must be open for this to work!
*
* Returns false in case it failed.
*/
private boolean setRaidType(int newType, int currentType) {
final Color off = new Color(147, 147, 147); // color of center pixel of turned off button
MarvinSegment seg = detectCue(cues.get("RaidLevel"));
if (seg == null) {
// error!
BHBot.log("Error: Changing of raid type failed - raid type button not detected.");
return false;
}
Point center = new Point(seg.x1 + 7, seg.y1 + 7); // center of the raid button
int move = newType - currentType;
Point pos = center.moveBy(move*25, 0);
clickInGame(pos.x, pos.y);
return true;
}
示例11: getCurrentLocation
import org.openqa.selenium.Point; //导入依赖的package包/类
/**
* @return Point in the middle of the drop area.
*/
@Override
public Point getCurrentLocation() {
Point inViewPort = null;
switcher.switchTo(getFramePath());
try {
Dimension size = dropArea.getSize();
inViewPort = ((Locatable) dropArea).getCoordinates().inViewPort()
.moveBy(size.getWidth() / 2, size.getHeight() / 2);
} finally {
switcher.switchBack();
}
return inViewPort;
}
示例12: expectLocation
import org.openqa.selenium.Point; //导入依赖的package包/类
/**
* Check Element Position
* @param xpath
* @param X
* @param Y
*/
public void expectLocation(String xpath, int X, int Y){
if(elementExist(xpath)){
Point point = be.getElementPosition(xpath);
if(point.getX()==X && point.getY()==Y){
logger.info("***** Position Right!\n");
HtmlLogUtil.appendLog2Html(htmlLogFile, 1, "元素位置检验正确 : ["+xpath+"]");
}
else{
logger.info("***** Position Error!\n");
HtmlLogUtil.appendLog2Html(htmlLogFile, 0, "元素位置检验错误 : ["+xpath+"] X="+point.getX()+" Y="+point.getY());
}
}
else
elementOut();
}
示例13: getLocation
import org.openqa.selenium.Point; //导入依赖的package包/类
@Override
public Point getLocation()
{
Point returnValue = null;
webDriver.getExecutionContext().startStep( createStep( "AT" ), null, null );
try
{
returnValue = baseElement.getLocation();
}
catch( Exception e )
{
webDriver.getExecutionContext().completeStep( StepStatus.FAILURE, e );
}
webDriver.getExecutionContext().completeStep( StepStatus.SUCCESS, null );
return returnValue;
}
示例14: getAt
import org.openqa.selenium.Point; //导入依赖的package包/类
@Override
public Point getAt()
{
getWebDriver().getExecutionContext().startStep( createStep( "AT" ), null, null );
Point returnValue = null;
try
{
returnValue = baseElement.getAt();
}
catch( Exception e )
{
getWebDriver().getExecutionContext().completeStep( StepStatus.FAILURE, e );
throw e;
}
getWebDriver().getExecutionContext().completeStep( StepStatus.SUCCESS, null );
return returnValue;
}
示例15: getLocation
import org.openqa.selenium.Point; //导入依赖的package包/类
@Override
public Point getLocation()
{
try
{
String x = null, y = null;
x=getAttribute( "x" );
y=getAttribute( "y" );
if ( x != null && y != null )
return new Point( Integer.parseInt( x ), Integer.parseInt( y ) );
else
return new Point( 0, 0 );
}
catch( Exception e )
{
return webDriver.findElement( by ).getLocation();
}
}