Inconsistence Execution of Watir-Web Driver? - watir

I've written a ruby script to test my application. Sometimes it seems to be executing without any error. When executing the same code next time however, the execution is not working as expected and it throws an error. Why it is behaving like this?
The error:
[remote server] file:///C:/Users/RAGHUN~1/AppData/Local/Temp/webdriver-profile20140818-5504-b2tdgg/extensions/fxdriver#googlecode.com/components/driver_componen
t.js:9470:133:in `FirefoxDriver.prototype.findElementInternal_': Unable to locat
e element: {"method":"tag name","selector":"body"} (Selenium::WebDriver::Error::
NoSuchElementError)
Also to overcome this issue tried Watir::always_locate = true but this is also not working. Am I missing any gem files? Can any one provide a suggestion?

Based on the "unable to locate element" error you're experiencing, if you're using Watir to manipulate the elements then I'd try applying ".wait_until_present" or ".when_present" to see if it's a case of that step in question executing too quickly. Hope that helps! Let us know!

Watir::always_locate = true
profile = Selenium::WebDriver::Firefox::Profile.new
profile.native_events = false
b=Watir::Browser.new:firefox, :profile => profile
This works for me

Related

Script execution failed error in aem groovy console

I am trying to update sling:resourceType and node name in aem using groovy script. Everytime when I run the script I am getting "Script execution failed error".
List<String> pages= new ArrayList<String>();
getNode('/content').recurse {rootNode ->
if (rootNode.hasProperty('property')) {
pages.add(rootNode.getParent().getPath());
}
}
#rmac, your script seems to be fine, Please try to navigate to locale level and execute the script.
I am assuming, it is getting timed out. Iterating through '/content' will take lot of time and might time out sometimes.
Try updating your path to '/content/sitename/en' or even deep in the hierarchy if you have a lot of content.
Please share the complete error in case if it is not working.
If it still helps:
import org.apache.sling.api.resource.ResourceResolver
import javax.jcr.Node
import javax.jcr.Session
session = resourceResolver.adaptTo(Session.class);
Node node = session.getNode("/content/we-
retail/us/en/jcr:content/root/hero_image");
node.getSession().move(node.getPath(), node.getParent().getPath() + "/" +
"test");
node.setProperty("prop", "value");
save()

How can I solve error of unexpected } in php

When I was running a process in ProcessMaker, I got error message "Fatal error in trigger", then I checked the error logs and found this
PHP Parse error: syntax error, unexpected '}' in /opt/processmaker/workflow/engine/classes/class.pmScript.php(216) : eval()'d code on line 9.
Could anyone tell me please what should I do?
Thank you so much for your help.
Here's the code :
public function executeAndCatchErrors($sScript, $sCode)
{
ob_start('handleFatalErrors');
set_error_handler('handleErrors');
$_SESSION['_CODE_'] = $sCode;
eval($sScript );
$this->evaluateVariable();
unset( $_SESSION['_CODE_'] );
ob_end_flush();
}
ProcessMaker supports Triggers, where you can embed PHP code directly into a workflow process.
The code you have pasted is actually part of the ProcessMaker source code, which evaluates the triggers during the execution of a workflow process.
It appears though there is a PHP syntax error in a trigger rather than the source code itself.
In order to fix this issue, I would look at the process triggers and check for PHP syntax errors. I would also try and run through the process and see at what point you get the error and then check the triggers that are defined around the task that caused the error.
For more information on triggers, see:
https://wiki.processmaker.com/3.0/Triggers

webdriver-sync running asynchronously?

I'm trying to create selenium tests that run each step synchronously, without using .then(), or async/await. The reason for this is that I want to create a set of functions that allow pretty much anyone on our test team, almost regardless of tech skills to write easy to read automated tests. It looks to me like webdriver-sync should give me exactly what I want. However, the following dummy code is producing problems:
var wd = require('webdriver-sync');
var By = wd.By;
var Chromedriver = wd.Chromedriver;
var driver = new Chromedriver;
driver.get('https://my.test.url');
var myButton = driver.findElement(By.cssSelector('[id*=CLICK_ME]'));
myButton.click();
It tries to run - browser is launched, and page starts to load... but the steps are not executed synchronously - it goes on and tries to find and click "myButton" before the page has finished loading, throwing a "no such element" error... which to me kinda defeats the point of webdriver-sync?! Can someone tell me where I am going wrong?
FWIW, I have webdriver-sync 1.0.0, node v7.10.0, java 1.8.0_74, all running on CentOS 7.
Thanks in advance!
You need to put double-quotes around "CLICK_ME" as it's a string value.
Generally, though, it's a good idea to Wait for specific elements because dynamic pages are often "ready" before all their elements have been created.

#javascript tag not working for cucumber test cases using capybara driver

I am getting this error when using #javascript tag for scenario :
Unable to load URL: http://testdomain.mentorstring.com:3000/login because of error loading http://testdomain.mentorstring.com:3000/login: Unknown error (Capybara::Webkit::InvalidResponseError).
when i am running the same without javascript tag i get no error and the test passes.
It is likely an error on the page. Check your browser console when loading the page. Also, see more details here: Capybara webkit invalid response error, how to debug?
This answer also provides a way to debug it: https://stackoverflow.com/a/12194920/769971
Try using following capybara configurations in your env.rb file
Capybara.configure do |config|
config.run_server = true
config.server_port = 3000
config.javascript_driver = :webkit
config.default_wait_time = 30
config.always_include_port = true
config.default_host = 'your_app_url'
config.app_host = 'http://your_app_url'
end

How to make ZombieJS wait indefinitely for a site

I'm using zombieJS to scrape a veeeeeeeery slow site. I tried many things to make it go slower, but I'm receiving lots of
TypeError: Cannot use 'in' operator to search for 'compareDocumentPosition' in null
errors.
I tried to add to my pressButton function the following:
browser.wait({waitDuration: '700s', element: "pre"});
while initializing the browser with this configuration:
browser = new Browser();
browser.maxWait = 10000000;
browser.runScripts = false;
browser.loadCSS = false;
browser.waitFor = 500000;
but I'm still receiving the above mentioned error after a few seconds...
I think this might apply to you: Zombiejs jQuery nullTypeError 'compareDocumentPosition'
your site is so slow, that the tag cannot be found early enough from zombie. Would you please so kind, to open a new issue for assaf on github? We tried to track down the cause of this random-error earlier, but now I think it's caused because zombie should wait for the first dom element to be loaded
I also had similar problem and it got solved by removing debug option, while creating instance of browser. Also downgrade to v1.4.1 as 2.0 is in alpha stage

Resources