トップページ > Selenium API(逆引き) > 【Ruby】position

【Ruby】position・・・ウィンドウの位置を取得する

【PR】業界トップクラスの「高単価報酬」「低マージン」を実現!レバテックフリーランス

「position」はウインドウ(ブラウザ)の座標位置を取得します。取得する座標位置はウインドウ左上隅になります。

説明

◆メソッド
  ・position
◆使用形態
  ・driver.manage.window.position
◆備考
  ・特になし
◆関連項目
  ・スクリーンショット(ファイル)を取得する
  ・ウィンドウのサイズを取得する

サンプル

require 'selenium-webdriver'
 
# Firefoxを起動
driver = Selenium::WebDriver.for(:firefox)
# Googleページに移行
driver.get('https://www.google.co.jp/')
#カレントウィンドウの座標(左上隅の座標)を取得
coordinate = driver.manage.window.position
#取得した座標を表示
print(coordinate)
※selenium version 4.1.0で動作確認をしています

実行結果

#<struct Selenium::WebDriver::Point x=4, y=4>
getPosition2
 ※GoogleおよびGoogleロゴはGoogle Inc.の登録商標であり、同社の許可を得て使用しています。

動画デモ

※字幕をONにすると解説のテロップが表示されます※


Warning: Invalid argument supplied for foreach() in /home/users/1/monda-muki/web/seleniumqref.com/api/ruby/window_get/Ruby_position.html on line 157

RubyAPIアクセス TOP10
過去1週間(4/12~4/18)

    カテゴリー

    環境構築

    APIリファレンス

    その他

    ページ上部へ戻る
    トップページ > Selenium API(逆引き) > 【Ruby】position
    Copyright © 2016- Seleniumクイックリファレンス All Rights Reserved