本文整理匯總了Java中org.openqa.selenium.Point.getX方法的典型用法代碼示例。如果您正苦於以下問題:Java Point.getX方法的具體用法?Java Point.getX怎麽用?Java Point.getX使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在類org.openqa.selenium.Point
的用法示例。
在下文中一共展示了Point.getX方法的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: 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;
}
}
示例4: 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();
}
示例5: pinch
import org.openqa.selenium.Point; //導入方法依賴的package包/類
/**
* Convenience method for pinching an element on the screen.
* "pinching" refers to the action of two appendages pressing the
* screen and sliding towards each other.
* NOTE:
* This convenience method places the initial touches around the element, if this would
* happen to place one of them off the screen, appium with return an outOfBounds error.
* In this case, revert to using the MultiTouchAction api instead of this method.
*
* @param el The element to pinch.
*/
public void pinch(WebElement el) {
MultiTouchAction multiTouch = new MultiTouchAction(this);
Dimension dimensions = el.getSize();
Point upperLeft = el.getLocation();
Point center = new Point(upperLeft.getX() + dimensions.getWidth() / 2,
upperLeft.getY() + dimensions.getHeight() / 2);
int yOffset = center.getY() - upperLeft.getY();
TouchAction action0 =
new TouchAction(this).press(el, center.getX(), center.getY() - yOffset).moveTo(el)
.release();
TouchAction action1 =
new TouchAction(this).press(el, center.getX(), center.getY() + yOffset).moveTo(el)
.release();
multiTouch.add(action0).add(action1);
multiTouch.perform();
}
示例6: zoom
import org.openqa.selenium.Point; //導入方法依賴的package包/類
/**
* Convenience method for "zooming in" on an element on the screen.
* "zooming in" refers to the action of two appendages pressing the screen and sliding
* away from each other.
* NOTE:
* This convenience method slides touches away from the element, if this would happen
* to place one of them off the screen, appium will return an outOfBounds error.
* In this case, revert to using the MultiTouchAction api instead of this method.
*
* @param el The element to pinch.
*/
public void zoom(WebElement el) {
MultiTouchAction multiTouch = new MultiTouchAction(this);
Dimension dimensions = el.getSize();
Point upperLeft = el.getLocation();
Point center = new Point(upperLeft.getX() + dimensions.getWidth() / 2,
upperLeft.getY() + dimensions.getHeight() / 2);
int yOffset = center.getY() - upperLeft.getY();
TouchAction action0 = new TouchAction(this).press(center.getX(), center.getY())
.moveTo(el, center.getX(), center.getY() - yOffset).release();
TouchAction action1 = new TouchAction(this).press(center.getX(), center.getY())
.moveTo(el, center.getX(), center.getY() + yOffset).release();
multiTouch.add(action0).add(action1);
multiTouch.perform();
}
示例7: setFirstPickerWheelValue
import org.openqa.selenium.Point; //導入方法依賴的package包/類
@Step
@When("установить пикер в первое значение")
public void setFirstPickerWheelValue() {
WebElement webElement = driver.findElement(By.xpath(pickerWheelXPath));
Point center = ((IOSElement) webElement).getCenter();
Dimension size = webElement.getSize();
int height = size.getHeight();
Point target = new Point(center.getX(), center.getY() - (int) (height * stepToLast));
TouchAction touchAction = new TouchAction(driver);
touchAction.press(target.getX(), target.getY()).release();
touchAction.perform();
}
示例8: setLastPickerWheelValue
import org.openqa.selenium.Point; //導入方法依賴的package包/類
@Step
@When("установить пикер в последнее значение")
public void setLastPickerWheelValue() {
WebElement webElement = driver.findElement(By.xpath(pickerWheelXPath));
Point center = ((IOSElement) webElement).getCenter();
Dimension size = webElement.getSize();
int height = size.getHeight();
Point target = new Point(center.getX(), center.getY() + (int) (height * stepToLast));
TouchAction touchAction = new TouchAction(driver);
touchAction.press(target.getX(), target.getY()).release();
touchAction.perform();
}
示例9: hover
import org.openqa.selenium.Point; //導入方法依賴的package包/類
@Override
public void hover(Element ele)
{
WebElement webEle = searchStrategyUtils.findStrategy(WebElement.class, ele).search(ele);
if(webEle == null)
{
logger.warn("can not found element.");
return;
}
if(!(ele instanceof FileUpload))
{
Dimension size = webEle.getSize();
Point loc = webEle.getLocation();
int toolbarHeight = engine.getToolbarHeight();
int x = size.getWidth() / 2 + loc.getX();
int y = size.getHeight() / 2 + loc.getY() + toolbarHeight;
try
{
new Robot().mouseMove(x, y);
}
catch (AWTException e)
{
// TODO Auto-generated catch block
e.printStackTrace();
}
}
}
示例10: CyclicQuad
import org.openqa.selenium.Point; //導入方法依賴的package包/類
public CyclicQuad(Point location, int height, int width){
int x = location.getX();
int y = location.getY();
//Set the selenium points
this.Point_A = new Point(x,y);
this.Point_B = new Point(x + width, y );
this.Point_C = new Point(x + width, y + height);
this.Point_D = new Point(x , y + height);
//Set the polygon
this.rectangle = new Rectangle(x,y,width,height);
}
示例11: getActualPoint
import org.openqa.selenium.Point; //導入方法依賴的package包/類
/**
* Gets the actual point.
*
* @param percentagePoint the percentage point
* @param screenDimension the screen dimension
* @return the actual point
*/
protected Point getActualPoint( Point percentagePoint, Dimension screenDimension )
{
if ( webElement != null )
{
if ( webElement.getLocation() != null && webElement.getSize() != null && webElement.getSize().getWidth() > 0 && webElement.getSize().getHeight() > 0 )
{
int x = percentagePoint.getX() * webElement.getSize().getWidth() + webElement.getLocation().getX();
int y = percentagePoint.getY() * webElement.getSize().getHeight() + webElement.getLocation().getY();
return new Point( x, y );
}
}
return new Point( (int) ( (percentagePoint.getX() / 100.0 ) * (double)screenDimension.getWidth() ), (int) ( (percentagePoint.getY() / 100.0 ) * (double)screenDimension.getHeight() ) );
}
示例12: getCenter
import org.openqa.selenium.Point; //導入方法依賴的package包/類
/**
* Method returns central coordinates of an element.
* @return The instance of the {@link org.openqa.selenium.Point}
*/
public Point getCenter() {
Point upperLeft = this.getLocation();
Dimension dimensions = this.getSize();
return new Point(upperLeft.getX() + dimensions.getWidth() / 2,
upperLeft.getY() + dimensions.getHeight() / 2);
}
示例13: elementScreenshot
import org.openqa.selenium.Point; //導入方法依賴的package包/類
/**
* Returns an element's screenshot.
*/
public BufferedImage elementScreenshot(WebElement lay) {
Point location = lay.getLocation();
Dimension size = lay.getSize();
//-- Check dimensions to prevent looking outside the window
int sx = location.x;
int sy = location.y;
int width = size.width;
int height = size.height;
int ex = location.getX() + width;
int ey = location.getY() + height;
if(ey > 0 && ex > 0) {
if(sx < m_image.getWidth() && sy < m_image.getHeight()) {
boolean truncated = false;
if(sx + width > m_image.getWidth()) {
width = m_image.getWidth() - sx;
truncated = true;
}
if(sy + height > m_image.getHeight()) {
height = m_image.getHeight() - sy;
truncated = true;
}
if(truncated) {
Dimension screen = m_wd.getSize();
System.err.println("WARNING: snapshot of " + lay + " has been truncated because part of it is off-screen (screen size is " + screen.width + "x" + screen.height + ")");
}
return m_image.getSubimage(location.getX(), location.getY(), width, height);
}
}
throw new IllegalStateException("CANNOT TAKE SCREENSHOT: object(" + sx + "," + sy + " to " +ex + "," + ey + " is not within the screen boundaries (" + m_image.getWidth() +"x" + m_image.getHeight());
}
示例14: Coordinates
import org.openqa.selenium.Point; //導入方法依賴的package包/類
public Coordinates(WebElement element) {
Point point = element.getLocation();
Dimension size = element.getSize();
this.width = size.getWidth();
this.height = size.getHeight();
this.x = point.getX();
this.y = point.getY();
}
示例15: isLeftOrientation
import org.openqa.selenium.Point; //導入方法依賴的package包/類
public boolean isLeftOrientation() {
if (tabHeaders.size() < 2) {
throw new InconsistentStateException("At least 2 tab headers required to determine if it is left oriented.");
}
Point tab1 = tabHeaders.get(0).getLocation();
Point tab2 = tabHeaders.get(1).getLocation();
return tab1.getX() == tab2.getX();
}