简体   繁体   English

在watir中创建新窗口

[英]new window creation in watir

I am new to watir. 我是watir的新手。 I am trying to create new ie window with 我正在尝试创建新的ie窗口

browser = Watir::Browser.new

but it gives error message like 但是它给出了错误信息

`user_is_bewildered': Error in the default values: :browser's value must be one of 'ie', 'firefox', or 'safari', and '' doesn't look right. (StandardError)

I donno how to set default browser. 我不知道如何设置默认浏览器。 Can some one help me? 有人能帮我吗? There is a another thread here . 有一个另一个线程在这里 But I am not able to understand what i need to do in ffi. 但是我无法理解我在ffi中需要做什么。

Thanks 谢谢

You need to tell it which browser to open. 您需要告诉它要打开哪个浏览器。 Try this: 尝试这个:

browser = Watir::Browser.new :ff

I haven't played around with watir since my last job so I had to look this up. 自上一份工作以来,我还没有和watir玩耍,所以我不得不查一下。 As I last recall, WATIR was not entirely integrated with FireWATIR (the Firefox based variant). 我上次记得说,WATIR并未完全与FireWATIR(基于Firefox的变体)集成在一起。 It's good to see that the two have apparently been reconciled in the meantime. 很高兴看到两者在此期间已被调和。

Taken from Watir in Five Minutes on Zeljko Filipin's github, BTW. 于5分钟的Watir,摄于Zeljko Filipin的github,BTW。

If this is the original Watir gem, then the following is how I used to launch it: 如果这是原始的Watir宝石,那么以下是我以前如何启动它的方法:

require 'rubygems'
require 'watir'

Watir::Browser.default = "firefox"
browser = Watir::Browser.new

# Whatever you want to do in watir

IamChuckB's answer may be a more efficient way of doing this, but having not used it, I'm not sure. IamChuckB的答案可能是一种更有效的方法,但是我不确定是否使用过它。

To install devkit, 要安装devkit,

  1. create a folder in the ruby directory called devkit 在ruby目录中创建一个名为devkit的文件夹
  2. get the devkit from here 这里获取开发套件
  3. unpack it into the devkit directory created in step 1 将其解压缩到步骤1中创建的devkit目录中
  4. add c:\\ruby193\\devkit\\bin;c:\\ruby193\\devkit\\wming\\bin to your path, of course adjusting for your ruby install directory 添加c:\\ ruby​​193 \\ devkit \\ bin; c:\\ ruby​​193 \\ devkit \\ wming \\ bin到您的路径中,当然会调整您的ruby安装目录

now open a command prompt to install the gem again 现在打开命令提示符以再次安装gem

c:\> gem install watir

The issue is resolved. 问题已解决。 Thanx for the the inputs. 感谢输入。 The issue was with wrong nokorigi gem installation, initially i installed x86-mswin32-60, i uninstalled it and tried with x86-mingw32, it solved. 问题出在错误的nokorigi gem安装上,最初我安装了x86-mswin32-60,我卸载了它并尝试使用x86-mingw32,它解决了。

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

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM