小编use*_*250的帖子

使用ruby watir测试是否存在html表元素

我想测试的是表元素是否存在?如果没有表格,那么我只想让脚本结束.但是如果有一个表我想将它输出到excel.

该脚本正在测试两个url:

http://www.mycounciltax.org.uk/results?postcode=EX99AE&search=Search

http://www.mycounciltax.org.uk/results?postcode=CV56bz&search=Search

第一个网址显示没有html表格的网页,第二个网页显示包含html表格元素的网页.

我已经尝试将以下脚本放在一起,但我不认为这是正确的.我确信我在测试table元素时犯了一个错误.

if browser.table.trs.collect {|tr| [tr[0].text, tr[1].text, tr[2].text]}.exists?
then content = browser.table.trs.collect {|tr| [tr[0].text, tr[1].text, tr[2].text]}
Run Code Online (Sandbox Code Playgroud)

如果你从下面的脚本中删除上面的代码,它将运行,但是当它找不到html表时会崩溃.

require "watir-webdriver"
browser = Watir::Browser.new :ff
browser.goto "http://www.mycounciltax.org.uk/results?postcode=CV56BZ&search=Search"

if browser.table.trs.collect {|tr| [tr[0].text, tr[1].text, tr[2].text]}.exists?
then content = browser.table.trs.collect {|tr| [tr[0].text, tr[1].text, tr[2].text]}
require 'win32ole'

application = WIN32OLE.new('Excel.Application')

application.visible = TRUE
workbook = application.Workbooks.Add();
worksheet = workbook.Worksheets(1);
worksheet.visible

row = 1; column = 0
content.each do |array|
array.each do |element|
worksheet.Cells(1,1).offset(row,column).value = element #.offset(row,column)
column += 1
end
row += …
Run Code Online (Sandbox Code Playgroud)

ruby watir watir-webdriver

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

Mysql查询将表格从长格式转换为宽格式

我有一个名为ContactAttrbiutes的表,其中包含每个联系人属性的列表.为这些联系人存储的数据类型包括:标题,姓名,姓氏电话号码等.

当前表

+-------------+-----------+------------------------------+
| attributeId | ContactId | AttributeValue               |
+-------------+-----------+------------------------------+
|           1 |         5 | Lady                         |
|           2 |         5 | Elizabeth                    |
|           3 |         5 | E                            |
|           4 |         5 | Anson                        |
|           5 |         5 |                              |
|           6 |         5 |                              |
|           7 |         5 |                              |
|           8 |         5 |                              |
|          10 |         5 | 0207 72776                   |
|          11 |         5 |                              |
|          12 | …
Run Code Online (Sandbox Code Playgroud)

mysql

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

symfony form isvalid eqauls false but has no error

I'm working on a symfony project which is already live and use doctrine. The problem I describe below is new and I'm certain it was caused by me but I can not confirm this as I'm unsure how to debug.

I have a simple form (it submits two fields) and I can see both these values have been submitted correctly by dumping the following:

$form->handleRequest($request);
Run Code Online (Sandbox Code Playgroud)

The problem is that although I can see the submitted values, the form does not …

php forms doctrine symfony

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

标签 统计

doctrine ×1

forms ×1

mysql ×1

php ×1

ruby ×1

symfony ×1

watir ×1

watir-webdriver ×1