How to select date in jQuery Datepicker? - watir-webdriver

I use Watir WebDriver.
I would be grateful if someone could show me how to enter a date into the jQuery Datepicker here:
http://jqueryui.com/datepicker/
The following code returns the error:
unable to locate element, using {:id=>"datepicker", :tag_name=>"input or textarea", :type=>"(any text type)"}
require 'watir-webdriver'
browser = Watir::Browser.new :firefox
browser.goto "http://jqueryui.com/datepicker/"
browser.text_field(:id, "datepicker").set("")
browser.link(:text, "Prev").click
browser.link(:text, "2").click

The jQueryUI demos are included through an iframe. Unlike other elements, you have to explicitly tell Watir to look inside a frame.
You just need to modify your script to include the frame:
# Go to the demo page
require 'watir-webdriver'
browser = Watir::Browser.new :firefox
browser.goto "http://jqueryui.com/datepicker/"
# Tell Watir to locate the elements within the frame
frame = browser.frame(:class => 'demo-frame')
frame.text_field(:id, "datepicker").set("")
frame.link(:text, "Prev").click
frame.link(:text, "2").click

Related

Unable to focus on a text field under Iframe through protractor

I am trying here the QuickView form of MS Dynamics CRM. The text fields are under IFrame. Through the below java script, it's accessible: fname
//enter fname value
browser.executeScript("window.onload = document.getElementById('NavBarGloablQuickCreate').contentWindow.document.getElementById('firstname_i').value = 'rupam'"); But only first name is selected, if we try to do for the rest fields, it's not working. Hence, decided to do it through protractor code,
// Swtich to iFrame
browser.switchTo().frame(element(by.id("NavBarGloablQuickCreate")));
// Setting anme in first name text field
element(by.id('firstname_i')).sendKeys('Indra');
But here, it says element is not contactable.
You almost had it but were missing the .getWebElement() from your switchTo line. This is required as per the protractor documentation.
// Switch to iFrame
browser.switchTo().frame(element(by.id("NavBarGloablQuickCreate")).getWebElement());
//set name
element(by.id('firstname_i')).sendKeys('Indra');
Can you try the below and let me know.
I am also facing same issue to work with Dynamics CRM Quick view forms.I am trying to set a values on different fields of Quick view forms using SendKeys().But the value is not showing and cursor is not moving from one control to anaother.I have tried to move TAB using protractor TAB values also.But it's not showing.

going to a javascript link with mechanize-firefox

There is a link on a page, and I want to go to it but it just a javascript command. How with mechanize do I go to the link?
<span>abc</span>
Without the page and its HTML and JS one can only guess. Note that the follow_link() methods don't work with JS links. The method below does, but of course I cannot test without the page.
Probably the best bet is to get link(s) as DOM object(s) for the click method
use WWW::Mechanize::Firefox;
# Get to your page with the link(s)
my $link = find_link_dom( text_regex => 'abc' ); # Or use find_all_links_dom()
$link->click();
# $mech->click( { dom => $link } ) # works as well
There are also text and text_contains relevant options (instead of text_regex), along with a number of others. Note that click method will wait, on a list of events, before returning. See for example this recent post. This is critical for pages that take longer to complete.
See docs for find_link_dom() and click methods. They aren't very detailed or rich in examples but do provide enough to play with and figure it out.
If you need to interrogate links use find_all_links_dom(), which returns an array or a reference to array (depending on context) of Firefox's DOM as MozRepl::RemoteObject instances.
my #links_dom = find_all_links_dom( text_contains => 'abc' );
# Example from docs for find_link_dom()
for my $ln (#links_dom) {
print $ln->{innerHTML} . "\n"
}
See the page for MozRepl::RemoteObject to see what you can do with it. If you only need to find out which link to click the options for find_link_dom() should be sifficient.
This has been tested only with a toy page, that uses __doPostBack link, with <span> in the link.

Hide an html element with coffeescript

I would hide an html element when a condition occurs.
I try to implement this code in coffeescript:
if byName == username
document.#prv-btn.style.display = 'none'
I have already tried this code but don't run.
The element #prv-btn is my html element. In my page i have some users and for each of them i have this #prv-btn. For example if i have ten users, i have ten #prv-btn, but only one i want that i see, each user see the button near his name.
How can I do?
There are a couple of issues:
You need to indent the body of if clauses in CoffeeScript.
You need to use getElementById() to actually select the button by its ID.
Also, I recommend using jQuery for DOM work such as this. It works just fine with the compiled CoffeeScript.
Code:
if byName == username
document.getElementById("prv-btn").style.display = 'none'
Here is a link to a jsFiddle that I made for this: http://jsfiddle.net/jonathanporta/tw3nn/1/

Select element and click

I desire to use watir webdriver to click on a link on a webpage. If I use firebug to find the unique selector - I obtain the following:
new_login > div:nth-child(6) > button:nth-child(1)
How can I select and click this button using watir-webdriver?
Clicking a direct translation of your xpath would be:
browser.element(:id => 'new_login').div(:index => 5).button.click
Depending on the actual html, you may be able to simplify it. For example, if there is only one button in the new_login element, you could just do:
browser.element(:id => 'new_login').button.click
The fewer things you need to locate the button, the more robust and maintainable your script will be.

TYPO3 extension: how to find certain TS setting

I found in typo3 admin side(/typo3), you can have two ways to set up TS,
you can set up through template->root, I think TS here will affect the whole site.
you can set up through template->certain page, it will only affect this page.
So my question is:
If I want to find where(which page) has TS setting such as : code = LIST, how could I do?
Use Web > Template module it has tools, you can for an example use Template Analyzer for the search
Try querying the database in phpMyAdmin or similar. The following looks in Template Setup:
SELECT pid, config, constants
FROM sys_template
WHERE config LIKE '%code = LIST%'
Replace config with constants to look in Template Constants. pid is the page ID.
If it is not set in the TypoScript, it perhaps has been set in the plugin itself. Just check the plugin content element itself.
In the Template module, go to the page where the setting is in effect.
Use the TSOB (Typo Script Object Browser) to search for "list":
This must show you all TS for this page that contains "list".
If you don't see the setting you can run a cmd/ctrl-F Search over the entire results.
You would have to search for "[code] = LIST".
Which will lead you to the following entry:
Hovering over the label will produce the above tooltip. Copy the line number.
Now change to the Template Analyzer. Here, you can click through all cascading templates and search for the line number:
This is definitely the line that sets that value.
From the "Template hierarchy" tree you will easily find the template that contains the setting.