本文整理汇总了Java中org.openqa.selenium.Point.getY方法的典型用法代码示例。如果您正苦于以下问题:Java Point.getY方法的具体用法?Java Point.getY怎么用?Java Point.getY使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类org.openqa.selenium.Point
的用法示例。
在下文中一共展示了Point.getY方法的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: 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();
}
示例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: bounceThatWindow
import org.openqa.selenium.Point; //导入方法依赖的package包/类
@Test
public void bounceThatWindow(){
WebDriver driver = new FirefoxDriver();
driver.get("file://" + System.getProperty("user.dir") + "/jsrunner.html");
driver.manage().window().maximize();
Dimension fullScreenSize = driver.manage().window().getSize();
int changeWidth = 200; int changeHeight = 210;
int xDir = 8; int yDir = 8; int xDirIncrement = xDir; int yDirIncrement = yDir;
driver.manage().window().setSize(new Dimension(changeWidth,changeHeight));
Point position = driver.manage().window().getPosition();
String banner = "***BANG****........ AND THEY ARE OFF........ Automation can be fun. " +
" EvilTester.com present a javascript and browser" +
" animation using Selenium 2 WebDriver tribute to the" +
" sporting event that cannot be named lest we be sued";
int bannerStart = 0;
for(int bounceIterations = 0; bounceIterations < 1000; bounceIterations ++){
position = position.moveBy(xDir,yDir);
driver.manage().window().setPosition(position);
if(position.getX()>(fullScreenSize.getWidth() - changeWidth)){ xDir = -1 * xDirIncrement; }
if(position.getX()<0){ xDir = xDirIncrement; }
if(position.getY()>(fullScreenSize.getHeight() - changeHeight)){ yDir = -1 * yDirIncrement; }
if(position.getY()<0){ yDir = yDirIncrement; }
//try {Thread.sleep(20);} catch (InterruptedException e) {}
String displayBanner = banner.substring(bannerStart,bannerStart+30);
((JavascriptExecutor)driver).executeScript("document.title='" + displayBanner + "';");
bannerStart++;
if(bannerStart > banner.length()-35){banner += banner;}
}
driver.quit();
}