简体   繁体   English

如何使用Ruby或WATIR检索IE浏览器实例的进程ID?

[英]How to retrieve process ID for IE browser instance using Ruby or WATIR?

IE Browser instance is open. IE浏览器实例已打开。 How do I get the process id for the Browser instance or opened tab for the browser using WATIR or Ruby: 如何使用WATIR或Ruby获取浏览器实例的进程ID或为浏览器打开的标签:

require "Watir"
browser = Watir::Browser.new
browser.goto "www.google.com"
puts Watir::Browser::Process.process_id_from_hwnd browser.hwnd
require 'watir-classic'
browser = Watir::Browser.new
Watir::Browser::Process.process_id_from_hwnd browser.hwnd

here is the above tested via IRB 这是通过IRB进行的上述测试

C:\Users\Chuck>irb
irb(main):001:0> require 'watir-classic'
=> true
irb(main):002:0> browser = Watir::Browser.new
=> #<Watir::Browser:0x22f00454 url="about:blank" title="">
irb(main):003:0> Watir::Browser::Process.process_id_from_hwnd browser.hwnd
=> 3752

This is however newer version than you are using, so your mileage may vary 但是,这是比您使用的新版本,因此您的里程可能会有所不同

C:\Users\Chuck>gem list watir

*** LOCAL GEMS ***

commonwatir (4.0.0)
watir (5.0.0 x86-mingw32)
watir-classic (4.0.1)
watir-webdriver (0.6.11)

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

相关问题 如何使用Ruby使用Watir最大化浏览器(IE) - How to maximize browser (IE) with Watir using Ruby 如何使用Ruby在GUI中封装Watir浏览器实例? - How to encapsulate Watir browser instance in a GUI using Ruby? 如何使用ruby watir单击浏览器“停止加载此页面”? - how to click on browser “stop loading this page” using ruby watir? 强制浏览器使用带有Watir和Webdriver的Ruby加载 - Force browser to load using Ruby with Watir and Webdriver Ruby,Watir Classic和IE:除非具有焦点,否则浏览器将停止 - Ruby, Watir Classic and IE: Browser stops unless it has focus 更改Watir Webdriver在ruby中创建的浏览器的进程优先级 - Change Process Priority of a browser created by Watir Webdriver in ruby watir 浏览器对象可以在以后的 Ruby 进程中重用吗? - Can a watir browser object be re-used in a later Ruby process? 如何获得的文本值 <legend> 在ruby watir中使用xpath标记。(使用IE) - How to get Text value of <legend> tag using xpath in ruby watir.(using IE) 有没有人设法让Ruby 1.9.1上的IE使用Watir正常工作? - Has anyone managed to get Watir using IE on Ruby 1.9.1 working? 如何获取 Browser.text.include? 搜索变量? (使用 Watir 和 Ruby ) - How can I get Browser.text.include? to search for a variable? ( using Watir and Ruby )
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM