Note that there are some explanatory texts on larger screens.

plurals
  1. POPHP's shell_exec won't allow "Watir::Browser.new :firefox" to execute
    text
    copied!<p>I'm brand new to ruby and Watir, here's my issue...</p> <p>I have a MySQL DB with test data that I need. I've done a lot in the past with this data and so I have a whole library of PHP tools for accessing this data, marking data as in use/used/bad/etc, and in general I have a lot of time invested in the PHP framework. So I'd really like to use the PHP framework as a wrapper around the Watir script - for example, use PHP to grab test user login data from the DB and pass it to the ruby script for processing.</p> <p>I now have sites with javascript that need work/testing and PHP &amp; cURL can't deal with this. So I'm working with Watir-WebDriver on Ubuntu 10.10 (Maverick, Desktop not Server) for these sites. The problem I'm having is with the use of PHP's shell_exec of the ruby script with all the Watir code.</p> <p>The PHP shell_exec is executing the file - I can see it because I have some puts lines in the file which are being displayed. However, the code appears to be failing on the line</p> <pre><code>ff = Watir::Browser.new :firefox </code></pre> <p>I'm not getting an error from PHP.</p> <p>The PHP line is:</p> <pre><code>echo shell_exec('ruby /var/www/watir_test.rb'); </code></pre> <p>The ruby script works fine when I call it from a terminal window with the line:</p> <pre><code>ruby /var/www/watir_test.rb </code></pre> <p>I originally expected this was a permissions issue since it worked from the command line but not from a browser. However, since it can call the file well enough to return the hardcoded data I've provided for the test then ruby file permissions don't seem to be the issue. Could there be a permissions issue with opening a Firefox window from the www-data user?</p> <p>When I run </p> <pre><code>ruby -d -v /var/www/watir_test.rb </code></pre> <p>I get:</p> <pre><code>{:extension=&gt;:webdriver} {"app.update.enabled"=&gt;"false"} {"browser.link.open_newwindow"=&gt;"2"} {"browser.shell.checkDefaultBrowser"=&gt;"false"} {"extensions.update.enabled"=&gt;"false"} {"security.warn_entering_secure.show_once"=&gt;"false"} {"webdriver_assume_untrusted_issuer"=&gt;true} {"startup.homepage_welcome_url"=&gt;"\"about:blank\""} {"browser.tabs.warnOnClose"=&gt;"false"} {"extensions.update.notifyUser"=&gt;"false"} {"toolkit.networkmanager.disable"=&gt;"true"} {"security.warn_entering_weak.show_once"=&gt;"false"} {"webdriver_firefox_port"=&gt;"7055"} {"browser.download.manager.showWhenStarting"=&gt;"false"} {"extensions.logging.enabled"=&gt;"true"} {"network.manage-offline-status"=&gt;"false"} {"network.http.max-connections-per-server"=&gt;"10"} {"security.warn_submit_insecure"=&gt;"false"} {"security.warn_entering_weak"=&gt;"false"} {"security.warn_leaving_secure"=&gt;"false"} {"prompts.tab_modal.enabled"=&gt;"false"} {"security.warn_viewing_mixed.show_once"=&gt;"false"} {"dom.max_script_run_time"=&gt;"30"} {"webdriver_accept_untrusted_certs"=&gt;true} {"browser.safebrowsing.enabled"=&gt;"false"} {"security.warn_leaving_secure.show_once"=&gt;"false"} {"signon.rememberSignons"=&gt;"false"} {"javascript.options.showInConsole"=&gt;"true"} {"app.update.auto"=&gt;"false"} {"browser.EULA.3.accepted"=&gt;"true"} {"browser.tabs.warnOnOpen"=&gt;"false"} {"dom.disable_open_during_load"=&gt;"false"} {"network.http.phishy-userpass-length"=&gt;"255"} {"security.warn_entering_secure"=&gt;"false"} {"browser.startup.homepage"=&gt;"\"about:blank\""} {"browser.EULA.override"=&gt;"true"} {"browser.dom.window.dump.enabled"=&gt;"true"} {"browser.startup.page"=&gt;"0"} {"browser.link.open_external"=&gt;"2"} {"browser.search.update"=&gt;"false"} {"browser.sessionstore.resume_from_crash"=&gt;"false"} {"security.warn_viewing_mixed"=&gt;"false"} {"dom.report_all_js_exceptions"=&gt;"true"} {"webdriver_enable_native_events"=&gt;false} {"devtools.errorconsole.enabled"=&gt;"true"} </code></pre> <p>How do I get PHP to execute the shell_exec properly? The script works and my initial tests were run using firewatir (which shell_exec ran fine) but I am really wanting to use Watir-WebDriver instead of FireWatir - WatirWebDriver should be capable of running a Chrome browser (and IE on a Windows machine) while FireWatir can only run Firefox.</p> <p>Thanks Gabe</p> <p>Here's my "Create Browser" code:</p> <pre><code># Include the RubyGems file require 'rubygems' # Include the Watir-WebDriver file. require 'watir-webdriver' # Create the necessary objects def create_browser(proxy) # Setup the proper Firefox Profile profile = Selenium::WebDriver::Firefox::Profile.new profile.proxy = Selenium::WebDriver::Proxy.new :http =&gt; proxy puts "&lt;br&gt;Using proxy " + proxy + "..." #ff=FireWatir::Firefox.new :profile =&gt; profile ff = Watir::Browser.new :firefox #, :profile =&gt; profile puts "&lt;br&gt;Firefox ready..." return ff end </code></pre>
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload