在资本中加载资产

时间:2017-09-18 12:28:07

标签: cucumber capybara assets

我正在用黄瓜和水豚写一些验收测试。当我检查一个元素是否可见时(在我的css中我显示:none),capybara说它是可见的。我以为资产没有加载。如何使用测试加载它们?

1 个答案:

答案 0 :(得分:0)

听起来你正在使用<table class="table table-striped table-bordered turnover_list"> <thead> <tr class="sorting_1"> <th>Company</th> <th>Year</th> <?php if($_POST['selectall'] == 0) { $allCompanies = array(); $allCompanies[0] = getCompanyName($_POST['company']); $allCompanies[1] = getCompanyName($_POST['compare']); } if($_POST['frommonth'] != "" && $_POST['tomonth'] != "" && $_POST['fromyear'] != "" && $_POST['toyear'] != "") { $fromMonth = $_POST['frommonth']; $toMonth = $_POST['tomonth']; $fromYear = $_POST['fromyear']; $toYear = $_POST['toyear']; } else { $fromMonth = 0; $toMonth = 11; $fromYear = date('Y'); $toYear = date('Y'); } for($i=$fromMonth; $i<=$toMonth; $i++) { echo "<th>" . $months[$i] . "</th>"; array_push($selectedMonths, $months[$i]); } for($i=$fromYear; $i<=$toYear; $i++) { array_push($selectedYears, $i); } ?> <th>Total</th> </tr> </thead> <?php foreach($selectedYears as $year) { $turnoverTotal = 0; echo "<table class='table table-striped table-bordered turnover_list'>"; echo "<tbody>"; $monthTotal = array("January"=>"0", "February"=>"0", "March"=>"0", "April"=>"0", "May"=>"0", "June"=>"0", "July"=>"0", "August"=>"0", "September"=>"0", "October"=>"0", "November"=>"0", "December"=>"0"); foreach ($allCompanies as $companyName) { $companyTurnoverTotal = 0; echo "<tr>"; echo "<td style=''>" . $companyName . "</td>"; echo "<td style=''>" . $year . "</td>"; foreach ($selectedMonths as $month) { $sql = "SELECT SUM(mob + www) AS 'turnover' FROM turnover WHERE year = '" . $year . "' AND companyID = '" . getCompanyID($companyName) . "' AND month = '" . $month . "'"; $result = mysql_query($sql) or die(mysql_error()); $row = mysql_fetch_assoc($result); $companyTurnoverMonth = $row['turnover']; $monthTotal[$month] += $companyTurnoverMonth; $companyTurnoverTotal += $companyTurnoverMonth; echo "<td style=''>" . make_format($companyTurnoverMonth) . "</td>"; } $turnoverTotal += $companyTurnoverTotal; echo "<td style=' font-weight: bold; background-color:#d3d3d3;'>" . make_format($companyTurnoverTotal) . "</td>"; echo "</tr>"; } echo "<tr style='font-weight: bold;'>"; echo "<td style='background-color:#d3d3d3;'>Total</td>"; echo "<td style='background-color:#d3d3d3;'>" . $year . "</td>"; foreach($selectedMonths as $month) { echo "<td style='background-color:#d3d3d3;'>" . make_format($monthTotal[$month]) . "</td>"; } echo "<td style='background-color:#d3d3d3;'>" . make_format($turnoverTotal) . "</td>"; echo "</tr>"; echo "</tbody>"; echo "</table>"; } ?> </table> 驱动程序运行Capybara,它根本不处理JS,只有少量的内联CSS。您需要配置Capybara以使用功能更全面的驱动程序 - 请参阅https://github.com/teamcapybara/capybara/blob/master/README.md#drivers