我写了下面的代码,它使用了另一个目录中的.rb文件但是在执行这段代码时我收到一个错误:
require_relative '../page/site_element.rb'
#define new browser
browser=SiteElement.new("http://demo.mahara.org")
#input user name
browser.login_username.send_keys('Student1')
#input password
browser.login_password.send_keys('Testing1')
#click on submit button
browser.submit_button.click
#wait until the Logout link displays, timeout in 10 seconds
wait = Selenium::WebDriver::Wait.new(:timeout => 10) # seconds
wait.until {browser.logout_link }
#if logout link is displayed
isLogoutLinkDisplayed=browser.logout_link.displayed?
puts isLogoutLinkDisplayed
browser.close_browser
以下是我收到的错误:
D:/Ruby - POC/test/login_test.rb:1:in `require_relative': cannot load such file
-- D:/Ruby - POC/page/site_element.rb (LoadError)
from D:/Ruby - POC/test/login_test.rb:1:in `<top (required)>'
from -e:1:in `load'
from -e:1:in `<main>'
答案 0 :(得分:1)
您的$criteria = "2312";
if (!preg_match("/^[1-9][0-9]*$/", $criteria)) {
if (!preg_match("/^([a-zA-Z0-9 ]+)$/", $criteria)) {
if (!preg_match("/^[_a-z0-9-]+(\.[_a-z0-9-]+)*@[a-z0-9-]+(\.[a-z0-9-]+)*(\.[a-z]{2,})$/", $criteria)) {
$this->error = "Your search criteria of '" . $criteria . "'' is not a valid display name, email address, or ID.";
} else {
$column = "email_address";
}
} else {
$column = "display_name";
}
} else {
$column = "user_id";
}
echo $column;
位于site_element.rb
,而不是D:/Ruby - POC/pages
。
D:/Ruby - POC/page