Qiita Teams that are logged in
You are not logged in to any team

Log in to Qiita Team
Community
OrganizationAdvent CalendarQiitadon (β)
Service
Qiita JobsQiita ZineQiita Blog
1
Help us understand the problem. What is going on with this article?
@EigenPort_M

rubyとselenuimでsend_keysが使えないときの代替策

More than 3 years have passed since last update.

作戦

・入力したい文字列をクリップボードへコピー
・入力したいところへカーソルを合わせる
・貼り付け

クリップボードコピー用のgem


gem install clipboard

クリップボードへコピー


require 'clipboard'
Clipboard.copy('入力したい文字列') 

入力したいところへカーソルを合わせる


driver.find_element(:name, '入力したいとこのname').click

ctrl+vを実施

driver.action.key_down(:control).send_keys('v').key_up(:control).perform 

あとがき

なんかこんなエラーが出るんですsend_keys使うと。。。
これの対処法知ってたら教えてください。

C:/Ruby24-x64/lib/ruby/gems/2.4.0/gems/
selenium-webdriver-3.11.0/lib/selenium/webdriver/remote/
response.rb:69:in `assert_ok': unknown error: call function result missing 'value'
(Selenium::WebDriver::Error::UnknownError)

//出力されるログ
[mmdd/hhmmss.XXX:ERROR:process_reader_win.cc(123)] NtOpenThread:
 {アクセス拒否} プロセスはオブジェクトのアクセスを要求しましたが、アクセス権が与えられていません。 (0xc0000022)
[mmdd/hhmmss.XXX:ERROR:exception_snapshot_win.cc(88)] thread ID 36952 not found in process
[mmdd/hhmmss.XXX:WARNING:crash_report_exception_handler.cc(62)] ProcessSnapshotWin::Initialize failed

1
Help us understand the problem. What is going on with this article?
Why not register and get more from Qiita?
  1. We will deliver articles that match you
    By following users and tags, you can catch up information on technical fields that you are interested in as a whole
  2. you can read useful information later efficiently
    By "stocking" the articles you like, you can search right away

Comments

No comments
Sign up for free and join this conversation.
Sign Up
If you already have a Qiita account Login
1
Help us understand the problem. What is going on with this article?