I want to use the selenium webdriver Actions in Watir webdriver.Is it possible?
Also is it possible to use java code in watir webdriver.Please help.
I have gone through many forums and got some knowledge from http://jkotests.wordpress.com/2014/09/04/convert-selenium-webdriver-objects-to-watir-webdriver/,regarding the usage of Selenium in watir.Thanks to Justin KO for the post.
You can access the ActionBuilder by directly interacting with the Watir browser's underlying Selenium driver:
browser.driver.action
#=> Selenium::WebDriver::ActionBuilder
Many of the action methods expect a Selenium element as the parameter. You can locate the elements using Watir and then get the underlying Selenium element. For example:
element = browser.div
element.wd
#=> Selenium::WebDriver::Element
Putting it all together, you can perform an action like:
watir_element = browser.div
browser.driver.action
.key_down(:shift)
.click(watir_element.wd)
.key_up(:shift)
.perform
Related
I have application in Angularjs2, and developers have not been using ids into it. Now I have to implement the Protractor on same application. Is there anyway to implement the Protractor without using "absolute XPath"?
Thanks in advance!
Please find a huge range of locator-possibilities on the official Protractortest API Page
Every element on a page needs to be uniquely identifiable... else the page wouldn't work, no matter which technology. Therefore with the help of any of the above provided locator-possibilities you'll always find the element you're looking for.
And there is never a need for XPath, except for this only one. (though there is an parentElementArrayFinder introduced in the meantime, so not even that one exception is valid anymore)
UDPATE
If you could use XPath, you can for sure use CSS-Locators.
Here some examples for locators:
$('div.class#id[anyAttribute="anyValue"] div.child.somewhere-below-div-point-class')
element(by.cssContainingText('div[data-index="2"]', 'select this option'))
Or as a specific example the "Learn More" of the "Tree List" section of https://js.devexpress.com/ :
treeListSection = element(by.cssContainingText('div.tab-content h2', 'Tree List')).getDriver();
learnMoreBtn = treeListSection.element(by.cssContainingText('a.tab-button','Learn More'));
learnMoreBtn.click();
Those are just examples, but there is always a way to do it.
If you provide some example-HTML in your Question, I can direct you towards a solution.
UPDATE 2
For getting the Parent Web Element, one could use getDriver() as well
For audit purposes I got the requirment to create a tool where the authors can look at older versions of a CQ page. I managed to get the available versions with the JCR VersionManager using the following code (used in a SlingServlet with cq:Page as the resourceType):
Session session = request.getResourceResolver().adaptTo(Session.class);
VersionManager vm = session.getWorkspace().getVersionManager();
VersionHistory versionHistory = vm.getVersionHistory(request.getResource().getPath());
VersionIterator vIt = versionHistory.getAllVersions();
while (vIt.hasNext()) {
Version version = vIt.nextVersion();
String no = version.getName();
Calendar createdDate = version.getCreated();
// do something with it
}
The path of the version points to e.g. /jcr:system/jcr:versionStorage/d6/23/4f/d6234f36-3360-4024-bee2-411020ac63ae/1.0 where I can see a child node called jcr:frozenNode which seems to represent the jcr:content node of this specific version.
How can I tell CQ to render the page in this version? I would expect an url with some parameter or selector, but I didn't find any documentation. I tried to reverse engineer it with the Timewarp, but there the URL seems to be still the original and the magic is hidden somewhere.
I was also in contact with adobe support regarding this, and beside the timewarp there seems to be no built in feature to achieve this. Nevertheless I did some experimenting and found a feasible workaround. Though it might not be easy for a complex layout with many fixed components in the template, luckily on our case we mainly have a parsys.
So my solution is the following: I load the older version through two selectors in the url:
I called it "versionhistory" which is used to take another rendering script called versionhistory.jsp on the page component.
contains the actual version/node name (replacing "." with "_" to not add more selectors
In my versionhistory.jsp I just add the correct path for the parsys component (taking the example path from the question), and include the same layout elements as in the default script e.g. page.jsp:
<cq:include path="/jcr:system/jcr:versionStorage/d6/23/4f/d6234f36-3360-4024-bee2-411020ac63ae/1.0/jcr:frozenNode/par" resourceType="foundation/components/parsys" />
I have a simple test setup:
component displayname="test1" extends="test2"
{
remote Any function ping1() {}
}
component displayname="test2"
{
remote Any function ping2() {}
}
When I cal the cfc using test1.cfc?wsdl something strange happens.
When I tell my application to use WSDL version 1 using this.wssettings.version everything looks fine, pretty much the same as in CF9. But when I tell it to use version 2 the function "ping2" does not show up in my definition xml.
Why doesn't WSDL 2 show my extended function "test2" when I call test1.cfc?wsdl ??
I tried this on ColdFusion 10 and both WSDL and WSDL2 do not show the inherited methods. I only see the ping1() function of the test1.cfc, I do not see ping2() inherited from test2.cfc. If you change the "Select web service version" value in the ColdFusion Administrator from 2 (the default) to 1, then ColdFusion 10 performs as ColdFusion 9 does and shows both methods.
On ColdFusion 9, the WSDL shows both methods.
In my opinion, this is a bug in ColdFusion 10, you should log it with Adobe (https://bugbase.adobe.com/), and post the bug number here so others can vote for it. This could break existing functionality if people upgrade without changing the default web services version.
I tried this exact code on CF 9.01 and did not get the same result. My WSDL shows both methods. Something is unique about your CF install - perhaps the wrong version of Axis or something? I'm sorry I can't be more helpful - but I'm struggling to figure out a way to duplicate your issue.
We have quite a number of .xqy files in several folders.
Sometimes, I need to invoke an .xqy file (via Marklogic's CQ) to test if it's working.
But I find it rather cumbersome to have to know what parameters to pass in and specify them in the xquery in CQ.
Is there a tool out there that would generate an HTML form that presents to me the parameters of a given .XQY file and invokes it when I press a "submit" button ?
If there is none out there, would somebody here know of how to make such an HTML form ? Right now, I can't seem to find any readily-available xdmp or xquery commands to tell me if an .XQY file is invocable or what parameters it expects to be fed.
Danny
The XQuery standard doesn't support introspection, nor does MarkLogic provide any functions that help with that. The closest you can get with this is using the XQDoc documentation code that is capable of parsing the XQuery code itself and producing descriptions of all function signatures within modules.
You can find more details about it here: http://developer.marklogic.com/code/xqdoc-ws
It doesn't provide a 'Submit' button, but using the XML output of xqdoc, you could make that yourself..
Good luck!
Another option would be to convert your XQuery to XQueryX and you can then process this as XML using XQuery (or XSLT) to generate an XForm or XHTML Form.
Since Danny mentioned unit testing, I'll risk plugging my own framework for that: https://github.com/mblakele/xqut
I usually run XQUT test suites in a cq buffer, but it would be easy enough to wrap one in a simple web page - with or without a form.
I'm trying to set up some functional/acceptance/integration testing using Cucumber for my PHP project. I'm trying to understand the best approach to implementing these types of tests.
I understand that Selenium can test javascript, but Selenium is slow and I don't always need to test javascript. I'm looking for a "headless browser" equivalent for PHP.
Would either of these be classified as "headless browsers?"
SimpleTest web testing
Zend_Test_PHPUnit_ControllerTestCase
What have you done to implement integration testing of your Zend Framework project?
If you set up Cucumber to use Webrat, you can set up Webrat to use Mechanize by default. Mechanize is essentially a headless browser. This is what my env.rb file looks like:
# RSpec
require 'rspec/expectations'
# Webrat
require 'webrat'
require 'test/unit/assertions'
World(Test::Unit::Assertions)
Webrat.configure do |config|
config.mode = :mechanize
end
World do
session = Webrat::Session.new
session.extend(Webrat::Methods)
session.extend(Webrat::Matchers)
session
end
Also, according to this article, you can set up Cucumber to use Capybara and configure it to use Celerity (a headless browser with javascript support). It also includes instructions on how to configure Capybara to use Selenium RC (which I thought was not possible). I have not attempted this approach yet, so I don't know how well it works.
Why not use behat ( http://behat.org/ ) ?
It should have all the requirements you listed above, and it's written in php.
It has a SahiDrvier to handle "in-browser" testing, and a Simple php browser too.
give a try to Codeception: http://codeception.com
UPDATE:
It's like Capybara , but with a PHP DSL. With codeception you can do something like this:
$I = new WebGuy($scenario);
$I->wantTo('create wiki page');
$I->amOnPage('/');
$I->click('Pages');
$I->click('New');
$I->see('New Page');
$I->fillField('title', 'Hobbit');
$I->fillField('body', 'By Peter Jackson');
$I->click('Save');
$I->see('page created'); // notice generated
$I->see('Hobbit','h1'); // head of page of is our title
$I->seeInCurrentUrl('pages/hobbit');
$I->seeInDatabase('pages', array('title' => 'Hobbit'));
You can use Selenium2 for browsing, or a PHPBrowser (headless) for better performance on js less scenarios (PHPBrowser doesn't execute javascript)
Update: It looks like Akephalos hasn't been updated in a while, so it might not be a good solution for working with a newer version of Capybara.
Use Capybara (a replacement for Webrat) and Akephalos (a headless browser). Capybara is used to interact with Akephalos.
Example support/env.rb:
# Capybara configuration (using Akephalos)
require 'capybara/cucumber'
require 'akephalos'
Capybara.default_driver = :akephalos
Capybara.app_host = 'http://your.web.app'
Capybara.register_driver :akephalos do |app|
# available options:
# :ie6, :ie7, :ie8, :firefox_3, :firefox_3_6
Capybara::Driver::Akephalos.new(app, :browser => :firefox_3_6)
end
If you're using Cucumber, are you not already using Ruby? Why not use celerity or culerity?
I've used Cucumber with Celerity to test a Struts 2 app as well as a ColdFusion 8 app. Basically, you use Celerity and JRuby (which wraps HtmlUnit) or Culerity which runs on native ruby, to drive your browser.
I suggest looking at one of these two projects to help you get started:
Cheesy UI Testing - Corresponding Blog
WatirMelon Page Objects - Corresponding Blog
First of all, you should use Capybara (a replacement for Webrat). It's used to simplify and standardize the DSL used to interact with the browser and provides some nice features.
Even though Selenium is a little slow, it's easy to use to get started since it comes bundled with Capybara. FYI: it defaults to using Firefox.
Example support/env.rb:
require 'capybara/cucumber'
Capybara.app_host = "http://your.app.com"
Capybara.default_driver = :selenium
Now that you're using Capybara, you should use capybara-webkit driver (a truly headless browser which uses Webkit behind the scenes). There's a little bit of setup involved, but once you've done that, the speed is improved from using Selenium.
Example support/env.rb:
require 'capybara/cucumber'
Capybara.app_host = "http://your.app.com"
Capybara.default_driver = :webkit