Obtaining selected item in dynamic radio button - regex

I have got radio button like this:
<span><input onClick="if (EventHandlers.valueChanged(event, this)==false) return false;" class="radio"
label="Temp label" type="radio"
id="TempId_01" onblur="EventHandlers.onBlur(event)"
name="TempId"
value="01" delayOnChange="true" checked></input></span>
i want to get a value of checked item. I have tried smth like this (by xpath):
//input[#checked and #name="TempId"]/#value
However this not work at all, is it valid?

XPath queries need to return physical DOM elements that Selenium can work with. Selenium is then responsible for grabbing any attributes, details or properties from that element - your query is, by this point, all over and done with.
So, you'll need something like:
driver.findElement(By.xpath("//input[#checked and #name="TempId"]")).getAttribute("value");

Related

Form variable populated in request, but empty string on receiving form

Something weird or something obvious.
I've inherited a coldfusion application, which I need to work with as it is for the meantime, including the widespread use of <CFFORM> etc.
We have a select list as follows:
<cfselect
class="selGroup"
query="get_merchant_categories"
name="category_id"
display="category_name"
value="unique_id"
onclick="document.getElementById('Merchant_Groups_Form').submit();"
size="15">
</cfselect>
This produces the following in the DOM:
<select name="category_id" id="category_id" class="selGroup" onclick="document.getElementById('Merchant_Groups_Form').submit();" size="15">
<option value="1">Equestrian Sports</option>
<option value="2">Other</option>
</select>
and the following page output:
Upon clicking the first item in the select list (Equestrian Sports), the request is seen as follows (NOTE: CSRFTOKEN is a hidden form field):
And the dump at the top of the receiving page is:
So, all is good there.
HOWEVER, when I click the second item in the list ("Other"), the request is OK and looks like this:
But, the dump on the receiving page looks like this:
Been trying to figure this out for over an hour and have no idea what is going on. Maybe someone's come across this before.

Emberjs 1.8 handlebars "view select" set default value/prompt text with variable

I want to set a default value or prompt a text to my select dropdown, I have managed to get the correct content into the select, but I want to be able to have a default value that differs from the content, for example " select country " and then list the countries.
This is how the select looks like so far, and the testing variable looks like this: testFillSelect: "Select Country..",
<div class="form-group">
<label>Countries:</label>
{{view "select2"
prompt="Select country.."
content=countries
optionValuePath="content.id"
optionLabelPath="content.name"
selectionBinding=testFillSelect
selection=countries.id
class="form-control"}}
</div>
The problem is, the selectionBinding doesn't seem to work as it does nothing, and niether does the prompt unless it's a blankspace in a string. I have tried select and select2, didn't make any difference either.
Does anyone have any idea of how to do this properly?
I thought I'd just leave an answer here in case anyone stumbles upon the same problem in the future, with this ember version.
Inspired by Lux comment, I passed an object as the first object in the content array instead, I did this using unshiftObjects which is supported by this ancient ember version believe it or not. (The first object is what is shown in the select if there's data in it & there's no prompt in the select view)
Code example of what I did:
this.set('countries', countries.unshiftObjects({id:-1, name:"Select country.."}));
And a validation that checks if a post is made with id -1 and in that case treat it as if nothing was selected.
Note that there are probably better ways to go about this & this is a workaround, but it's what worked for me :)

Capybara save_and_open_page doesn't reflect radio buttons tate

I am trying to select the radio button for the freelancer the code is as follows (when we inspect the element on browser)
<label for="registration_payer_type_business"><input checked="checked" id="registration_payer_type_business" name="registration[payer_type]" type="radio" value="business">
Company
</label>
<label for="registration_payer_type_freelancer"><input id="registration_payer_type_freelancer" name="registration[payer_type]" type="radio" value="freelancer">
Freelancer
</label>
I have tried
page.choose("registration_payer_type_freelancer")
This doesn't give any error but when and save and open page in capybara still the radio box is not selected against freelancer. I would appreciate if people can give example using xpath and choose.
The real issue you're most likely having is that save_and_open_page saves the HTML with the current attribute values NOT the current property values . This means the fact that you've selected a radio button (which changes the checked property value, not attribute value, won't necessarily be shown). You're better off using save_and_open_screenshot if you want to see the current state of a page. That being said below is ways you can select radio buttons.
To select a specific radio button with Capybara you can use the id, name, label text, and value too if needed to make unique (with name for instance)
choose('registration_payer_type_freelancer') # id
choose('registration[payer_type]', option: 'freelancer') # name and value to make unique
choose('Freelancer') # label text
choose(option: 'freelancer') # just value if the only radio button with that value
In all those cases, if the actual radio button input element is non-visible (for styling purposes, etc) on the page and you want to instead click the visible label you can pass allow_label_click: true
choose('registration_payer_type_freelancer', allow_label_click: true) # find by id and select by clicking the label if input is non-visible
Other options you could use is to just find by CSS (the :css argument can be ignored if your default selector type is the default :css)
find(:css, '#registration_payer_type_freelancer').click
You could also use XPath queries to locate the element, but they're really not necessary 98% of the time (more people correctly understand CSS and with scoping of finders it can generally be used to get any element), and have issues to be aware of - https://github.com/teamcapybara/capybara/blob/master/README.md#beware-the-xpath--trap
find(:xpath, './/input[#value="freelancer"]').click

OrchardCMS Replacement Tokens for Query Results displaying HTML tags instead rendering them

I am having problems understanding the token system for the output of query / projections.
If I leave the property as is it displays the text content with HTML formatting intact.
But I need to wrap it with a tag, the html tags get displayed as text.
Rewrite Results -> Rewrite output
<div class="collapse" id="toggle_{Content.Id}">
{Content.Fields.CaseStudy.ClientChallenge} </div>
I am trying to create a collapsible text area, I already have a button that hides/unhides the content.
Why is it displaying as text instead of rendering the tags properly.
I think this is because I don't know how replacement tokens work.
Another example problem is up one level on the edit Layout, I want to set the item class to work-item {Category}, Category being the name/title of a property, which I am using for grouping.
Right above the projection: I want to include some html that lists all the Categorys in a ul i.e. data-filter=".experiential" I have tried things like: work-item {Category} and work-item {Content.Fields.CaseStudy.Category}. Category is a "term" (?) from a taxonomy.
I feel like I am failing to understand how it all works.
Submitted as a bug https://github.com/OrchardCMS/Orchard/issues/7355
Will edit and post if it is fixed. In case anoyong else comes across this issue.

CustomItemGenerator and the Page Editor

Sitecore 6.6 Update 4
We're using CustomItemGenerator 1.0 and I was using this to help build a primary navigation menu for a site. This worked as expected and everything was rendered properly.
My problem is when I attempt to edit the menu via Page Editor; I don't even see the menu.
I use a repeater and repeat over a list of links to include in the nav. Due to the way the HTML was created, each LI element needs to have its own, specific ID ("Nav Id" Field in Sitecore) that ties into the CSS. Code inside of my repeater's ItemDataBound event:
// Cast the item using CustomItemGenerator-generated class
GenericContentPageItem navItem = (GenericContentPageItem)e.Item.DataItem;
liMenuItem.ID = navItem.NavId.Rendered; // I tried "navItem.NavId" by itself as well
So while this renders properly in the browser, it doesn't when I'm in Page Editor:
<li id="<input id='fld_B72EB6696DCF41A49671972D5EA5DEB8_2163B90C08AB4A18970A7F3ECE79DCFC_en_1_f71bd37d18d146c19e222e89fcffe278_3' class='scFieldValue' name='fld_B72EB6696DCF41A49671972D5EA5DEB8_2163B90C08AB4A18970A7F3ECE79DCFC_en_1_f71bd37d18d146c19e222e89fcffe278_3' type='hidden' value=" Home?="">
... instead of it rendering like this:
<li id="Home">...</li>
Now, that having been said, I can change my code to not use the CustomItemGenerator and it works fine in the browser and Page Editor as follows:
GenericContentPageItem navItem = (GenericContentPageItem)e.Item.DataItem;
Item nav = Sitecore.Context.Database.GetItem(navItem.ID);
liMenuItem.ID = nav.Fields["Nav Id"].ToString();
I would like to avoid having to hardcode field names in my code, which is why I am using CustomItemGenerator. Is there something that I'm doing wrong with my code that it doesn't want to work in Page Editor?
Thanks!
If you need the actual value out of the field regardless of if you are in the page editor or not, you want to use the Raw property:
liMenuItem.ID = navItem.NavId.Raw;