小编mar*_*875的帖子

Node.js读取并执行Ruby文件?

是否有一个npm可以安装和/或使用ruby文件并在node.js内执行?我很好奇,因为我想要同时运行两个不同的ruby脚本.

javascript ruby rubygems node.js npm

6
推荐指数
1
解决办法
2300
查看次数

如何在Ruby中读取文件时删除换行符

我正试图摆脱括号[]和新线的\n印刷.

我的代码看起来像:

name1 = File.readlines('first.txt').sample(1)
name2 = File.readlines('middle.txt').sample(1)
name3 = File.readlines('last.txt').sample(1)

name = print (name1.strip 
    print name2.strip 
    print name3.strip)

puts name
Run Code Online (Sandbox Code Playgroud)

我希望输出看起来像JoshBobbyGreen.但是,它看起来像:

[\"Josh\\n\"][\"Bobby\\n\"][\"Green\\n\"]
Run Code Online (Sandbox Code Playgroud)

我已经尝试使用.gsub,chompsplit但也许我使用他们错了.

ruby newline line file-read chomp

4
推荐指数
3
解决办法
1万
查看次数

单击带有selenium-webdriver的复选框

我正在使用tumblr测试我的应用程序,我必须在我执行程序时登录和注销.在这样做时,我无法点击一个不断弹出的复选框.如何在python中使用selenium-webriver点击它?

我已经尝试过选择xpaths,... by_ids和by_classes,它们将无法工作,所以现在我正在尝试使用鼠标坐标来物理点击该项目.(这是在tumblr登录页面,fyi)

在此输入图像描述

以上是我想要选择的项目的html.

(编辑:)我有以下选择器:

#checkbox = driver.find_element_by_id("recaptcha-anchor")
#checkbox = driver.find_element_by_id("g-recaptcha") 
#driver.find_element_by_xpath("//*[@id='recaptcha-token']")
#driver.find_element_by_css_selector("#recaptcha-anchor")
#driver.find_element_by_xpath("//*[@id='recaptcha-anchor']")
#driver.find_element_by_id("recaptcha-token").click()
#driver.find_element_by_class_name('rc-anchor-center-container')
#checkbox = driver.find_element_by_id("recaptcha-anchor")
Run Code Online (Sandbox Code Playgroud)

python selenium tumblr webautomation python-3.x

3
推荐指数
2
解决办法
7803
查看次数

如何使用 watir-webdriver 选择下拉菜单项

我正在使用 watir-webdriver 来自动化和测试应用程序。在此过程中,我需要单击下拉菜单并选择一个值,但是 watir 似乎无法选择该项目。请帮忙?

我的代码:

browser.text_field(:id => "user_username").set "#{username}"
browser.select_list(:id => 'user_date_of_birth_month').clear
puts browser.select_list(:id => 'user_date_of_birth_month').options
browser.select_list(:id => 'user_date_of_birth_month').select "9"
Run Code Online (Sandbox Code Playgroud)

HTML:

 <label class="sc-font-light sc-text-light next-light-label" for="user_date_of_birth_month
2. When were you born?<span class="inline-help"><span class="content hidden">For information on why we ask for your date of birth, see <a href="http://help.soundcloud.com/customer/portal/articles/1481474-why-do-you-need-my-date-of-birth-" target="_blank">this help center article</a>.</span></span>
Run Code Online (Sandbox Code Playgroud)

<div class="width_1_2"><select id="user_date_of_birth_month"name="user[date_of_birth][month]">
 <option value="">Month</option>
 <option value="1">January</option>
 <option value="2">February</option>
 <option value="3">March</option>
 <option value="4">April</option>
 <option value="5">May</option>
 <option value="6">June</option>
 <option value="7">July</option>
 <option value="8">August</option>
 <option value="9">September</option>
 <option value="10">October</option>
 <option value="11">November</option>
 <option …
Run Code Online (Sandbox Code Playgroud)

ruby automation watir webautomation watir-webdriver

1
推荐指数
1
解决办法
5160
查看次数

如何循环跳过以前引用元素的数组?

有没有办法循环遍历两个数组并让它们每次引用某个元素?例如:

first_array = ['a', 'b', 'c', 'd']
second_array = ['e', 'f', 'g', 'h']

first_array.each |item| puts item.get(second_array)
Run Code Online (Sandbox Code Playgroud)

结果看起来像:

a would work with e
b would work with f
c would work with g    
d would work with h
Run Code Online (Sandbox Code Playgroud)

我试图这样做,以便当first_array传递变量from 时second_array,它会移动到下一个变量second_array,跳过以前使用的变量.

ruby arrays

0
推荐指数
1
解决办法
58
查看次数