I'm encountering an error when attempting to search for regexes within a page. I used the following to actually locate the regex, but I'm receiving various errors.
...
browser.script.html.include? "event49"
The errors seem to be browser (and possibly environment) dependent. I've tested back and forth between Safari, Chrome, and Firefox. Firefox seems to have intermittent issues. Chrome, almost constant. I've also tested this between my PC and Mac and it seems to be standard across the board.
I have no issues with Safari.
This error is from Firefox:
[remote server] resource://fxdriver/modules/web_element_cache.js:7204:in `fxdriver.cache.getElementAt': Element not found in the cache - perhaps the page has changed since it was looked up (Selenium::WebDriver::Error::StaleElementReferenceError)
This error is from Chrome:
/Library/Ruby/Gems/1.8/gems/selenium-webdriver-2.29.0/lib/selenium/webdriver/remote/response.rb:52:in `assert_ok': getElementTagName execution failed; (Selenium::WebDriver::Error::StaleElementReferenceError)
Element does not exist in cache
Any help is much appreciated!
UPDATE:
Please see script below:
require "rubygems"
require "watir-webdriver"
require "watir-webdriver-performance"
require "rspec"
include Watir
require 'logger'
browser = Watir::Browser.new :chrome
test_site = 'http://laughlin:driveafirestone#fcac-rebrand.laughlin.com/'
browser.goto(test_site)
year_select = browser.select_list(:id => 'universal-year')
browser.select_list(:id => 'universal-year', :disabled => 'disabled').wait_while_present
year_select.select '2010'
make_select = browser.select_list(:id => 'universal-make')
browser.select_list(:id => 'universal-make', :disabled => 'disabled').wait_while_present
make_select.select 'Volkswagen'
model_select = browser.select_list(:id => 'universal-model')
browser.select_list(:id => 'universal-model', :disabled => 'disabled').wait_while_present
model_select.select 'Jetta'
submodel_select = browser.select_list(:id => 'universal-submodel')
browser.select_list(:id => 'universal-submodel', :disabled => 'disabled').wait_while_present
submodel_select.select '2.0T TDI Sedan'
zipcode_input = browser.text_field(:id => 'universal-selectorZip')
zipcode_input.set '53202'
browser.button(:id => 'universal-submit-tires-quote').click
browser.script.html.include? "event49"
browser.close
How about you use
Watir::Wait.until(30) { browser.text.include? "event49" }
Related
I am trying to set up my CakePHP 3.8 project on a GCP "Compute Engine" VM.
I have set up my app.php to use the following DB configuration:
'className' => 'Cake\Database\Connection',
'driver' => 'Cake\Database\Driver\Mysql',
'persistent' => false,
'datasource' => 'Database/Mysql',
'persistent' => false,
'host' => 'localhost',
'username' => 'user',
'password' => 'password',
'database' => 'dbname',
'prefix' => '',
'encoding' => 'utf8',
'timezone' => 'UTC',
'cacheMetadata' => true,
'log' => false,
'flags' => [
PDO::MYSQL_ATTR_INIT_COMMAND => "SET ##SESSION.sql_mode='';",
// uncomment below for use with Google Cloud SQL
PDO::MYSQL_ATTR_SSL_KEY => CONFIG.'ssl/client-key.pem',
PDO::MYSQL_ATTR_SSL_CERT => CONFIG.'ssl/client-cert.pem',
PDO::MYSQL_ATTR_SSL_CA => CONFIG.'ssl/server-ca.pem',
PDO::MYSQL_ATTR_SSL_VERIFY_SERVER_CERT => false
],
'cacheMetadata' => true,
'log' => false,
My problem happens when I try to run migrations. The site works just fine with the above configuration, however, if I run
$> php bin/cake.php migrations migrate
I get a slew of errors saying that it cannot connect, access denied for user#host.
If I add
'ssl_key' => CONFIG .'ssl/client-key.pem',
'ssl_cert' => CONFIG . 'ssl/client-cert.pem',
'ssl_ca' => CONFIG . 'ssl/server-ca.pem',
I get an error:
Caused by: [PDOException] PDO::__construct(): Peer certificate CN=`gcpname:gcpserver' did not match expected CN=`111.111.111.111' in /var/www/mydomain.com/vendor/robmorgan/phinx/src/Phinx/Db/Adapter/PdoAdapter.php on line 79
I guess this is because the migrations plugin still doesn't pass the flags or custom mysql_attr_* options over to the Phinx connection configuration, see this issue:
https://github.com/cakephp/migrations/issues/374
I don't think there's much that can be done here, other than adding support for flags / attribute options, or using Phinx directly (ie without the Migrations plugin).
I've pushed a PR that would add support for driver specific flags, you might want to give it a try and comment on the issue or the PR whether it works for you (it's for CakePHP 4.x (Migrations 3.x), I'll backport it for CakePHP 3.x (Migrations 2.x) in case it's being accepted):
https://github.com/cakephp/migrations/pull/478
I want to use capybara for headless browser but i want to use this driver: Selenium::WebDriver::Remote::Http::Default.new
How to use this driver for capybara? Need to know the browser initialization using that driver not poltergeist or webkit.
Here's the example for chrome initialization in capybara:
Capybara::Selenium::Driver.new(app, :browser => :chrome)
Selenium::WebDriver::Remote::Http::Default.new isn't a driver - it's an http_client that can be used by drivers - I think what you're asking for is to use an instance of Selenium::WebDriver::Remote::Bridge which can be done using
Capybara::Selenium::Driver.new(app, browser: :remote, ...)
where the ... includes other options like :http_client, :desired_capabilites, :url (url for the remote server that will control the actual browser)
The title of this questions mentions phantomjs but never mentions it in the actual question. If thats what you really want then it's
Capybara::Selenium::Driver.new(app, browser: :phantomjs, ...)
where there are similar options http_client, desired_capabilities, url, args, port
For Capybara, you can use Poltergeist driver on the top of Phantomjs. To use it you need to install it by gem install poltergeist or add this gem "poltergeist" to your Gemfile and run bundle install. Then add poltergeist option to your env.rb and change your Capybara.javascript_driver = :poltergeist. See the example below:
require 'capybara/poltergeist'
Capybara.register_driver :poltergeist do |app|
options = {
:js_errors => false ,
# :timeout => 120,
# :debug => true,
# :inspector => true,
# :window_size => [1280, 1024],
# :logger => false,
# :inspector => false,
# :visible => false,
:js => true,
:timeout => 10000,
:phantomjs_options => %w[--load-images=no]
}
Capybara::Poltergeist::Driver.new(app, options)
end
Capybara.javascript_driver = :poltergeist
I have a website in Kohana 3.0.7 and I have purchased SSL certificate. I have marked the success page to which pay pal transaction details are returned with https. After the database is updated, I added following code -
$this->request->redirect('business/fnc_manage');
But this page is loaded with https and not loaded properly on Google Chrome.
If I try as following, it gives me 500 error -
header("Location:"+url::base()+"business/fnc_manage");
exit();
How can I get rid of this ? Does this mean that I'll have to ensure that all the resources loaded should be served over https ?
If yes, then I might have to change all the paths. How can I do it for HTML helpers ?
I have not tried it but I'd say changing the base_url in your bootstrap.php could help:
Kohana::init(array(
'base_url' => 'https://yoururlhere.com',
'index_file' => FALSE,
'charset' => 'utf-8',
'cache_dir' => APPPATH . 'cache',
'errors' => TRUE,
'profile' => Kohana::$environment !== Kohana::PRODUCTION,
'caching' => Kohana::$environment === Kohana::PRODUCTION,
));
I am currently using
- firefox 13
- selenium-server-standalone-2.23.1.jar
- selenium-client (1.2.18)
- rspec 1.2.8
Selenium stops here even if page has fully loaded
08:49:43.888 INFO - Command request: waitForPageToLoad[300000, ] on session 2718493e6d4640eea76d6cb3ab1a6fc3
require 'rubygems'
require "selenium/client"
require "selenium/rspec/spec_helper"
describe "Google Search" do
attr_reader :selenium_driver
alias :page :selenium_driver
before(:all) do
#selenium_driver = Selenium::Client::Driver.new \
:host => "localhost",
:port => 4444,
:browser => "*firefox",
:url => "http://www.google.com",
:timeout_in_second => 10
end
before(:each) do
selenium_driver.start_new_browser_session
end
# The system capture need to happen BEFORE closing the Selenium session
append_after(:each) do
#selenium_driver.close_current_browser_session
end
it "can find Selenium" do
page.open "/"
page.title.should eql("Google")
page.type "q", "Selenium seleniumhq"
page.click "btnG", :wait_for => :page
page.value("q").should eql("Selenium seleniumhq")
page.text?("seleniumhq.org").should be_true
page.title.should eql("Selenium seleniumhq - Google Search")
page.text?("seleniumhq.org").should be_true
page.element?("link=Cached").should be_true
end
end
I wonder if the google page is using AJAX which is confusing the page load event.
When I went to http://google.com I noticed that submitting the search only added #q=selenium to the url.
This could likely be confusing selenium. Maybe instead of wait for pageload you can wait for page element
Some search element xpath (for example) /html/body/div[1]/div[3]/div[3]/div[6]/div[2]/div[3]/div/div[2]/div[2]/div/div/ol/div[2]/li[1]/div (ugly I know)
I've looked around and can't seem to find the answer to this... I'm trying to use net-ldap with rails.
in irb, I can run a quick bind and it works:
irb(main):003:0> ldap_con = Net::LDAP.new({:host => 'myhost.ad',
irb(main):004:2* :base => 'DC=myhost,DC=ad',
irb(main):005:2* :port => 389,:auth=>{:method=>:simple,:username => 'bsharpe#myhost.ad',
irb(main):006:3* :password => 'letmein' } } )
=> #<Net::LDAP:0x292089f0 #host="myhost.ad", #open_connection=nil, #encryption=nil, #auth={:password=>"letmein", :method=>:simple, :username=>"bsharpe#myhost.ad"}, #verbose=false, #port=389, #base="DC=myhost,DC=ad">
irb(main):007:0> ldap_con.bind
=> true
but if i run the app i get
no such file to load -- net/ldap
which is from my require net/ldap
I checked $LOAD_PATH and it does contain /usr/local/lib/ruby/gems/1.8/gems/net-ldap-0.1.1/lib
What am I missing here?
I had the same problem. Adding: require 'rubygems' before require 'net/ldap
For example:
#!/usr/bin/ruby -w
require 'rubygems'
require 'net/ldap'
ruby version 1.8.7 and net/ldap(0.3.1)