本文整理匯總了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();
}
}