How to select from a selection box with a variable in the name? - html

I am having trouble using selecting from this select element.
<select name="vehicle_attrs[position_count]" class="mb1"><option>Position / Quantity</option><option>Front</option><option>Rear</option></select>
I have tried
select('Front', :from=>'mb1')
select('Front', :from=>'vehicle_attrs[position_count]')
select('Front', :from=>'vehicle_attrs[1]')
All of them result in a can not find selection box error

I've never liked how restrictive Capybara's concept of a 'locator' is (i.e. must have a name/id/label), but if you dig into the source code, those helpful methods like select, click_on, and fill_in are just wrappers for find and some native method of Element, which takes arbitrary CSS, and works in almost all situations. In this case, you could use:
find('[name="vehicle_attrs[position_count]"]').find('option', text: 'Front').select_option
Since dropdowns often have multiple similar options, where one is a substring of the other, you might consider using an exact string match, like
find('[name="vehicle_attrs[position_count]"]').find('option', text: /\AFront\z/).select_option

From the docs for select - https://www.rubydoc.info/github/teamcapybara/capybara/Capybara/Node/Actions#select-instance_method - we can see that the from option takes "The id, Capybara.test_id atrtribute, name or label of the select box".
Neither 'mb1' or 'vehicle_attrs[1]' are any of those so they would be expected to fail.
'vehicle_attrs[position_count]' is the name so assuming the box is actually visible on the page (not replaced with a JS driven select widget, etc), that should work. If it doesn't, then edit your question and add the full exact error message you get when trying to use it. Of course if there is only one select box on the page with an option of 'Front' then you don't need to specify the from option at all and can just do
select 'Front'

Related

Html selector using Regex

So there is a page that I want to perform some action on with puppeteer. The problem is that there is a text area in which I want to type in something however the id of it is :
id="pin-draft-title-13a10e18-5a1e-49b9-893c-c5e028dc63e1"
As you might have guess for some reason only pin-draft-title remains the same but the whole number part changes for every refresh so puppeteer can't find it. I tried deleting the id and copying the selector itself the whoe #_Root div>div etc but that seems to be changing after sometime as well. So the main question is is there any way i can just select it using the pin-draft-title part and no matter what numbers follow it still selects it ?
You can use [id^=pin-draft-title-]
In case of javascript, if you want to select all the elements whos ID starts with a specified string or pattern, in your case "pin-draft-title", then consider using the following syntax.
document.querySelectorAll('[id^="pin-draft-title"]');

Filtering name with two condition

I have a sample list of student and grades/subject in this file
enter image description here
https://docs.google.com/spreadsheets/d/1NeHlUaRnbvdJ2yJ38fUETGgBoYseQ8CuXmwRCwObAlM/edit#gid=0
On the range A16:A I'd like to see the list of names who has the grades of around 90-100 when I check any of the checkbox on B15:k15
the first example is when I check all of the boxes
I will only see the first name on the list because he is the only one with the 90-100 scores on all subject
2nd example when I check B15 and C15
I will only see the 1st and 2nd names on the list because he's those who only able to get a 90-100 score on those two subjects.
Is there a way to do this kind of filtering? thank you so much
Since this is your first post, I'm going to go with the approach I think you'll find easiest to understand. It's a long formula (which I've placed in a new sheet called "Erik Help" in A16), but it's just a repeat of the same element several times:
=FILTER(A2:K11, IF(B15=TRUE, B2:B11>=90, B2:B11^0), IF(C15=TRUE, C2:C11>=90, B2:B11^0), IF(D15=TRUE, D2:D11>=90, D2:D11^0), IF(E15=TRUE, E2:E11>=90, E2:E11^0), IF(F15=TRUE, F2:F11>=90, F2:F11^0), IF(G15=TRUE, G2:G11>=90, G2:G11^0), IF(H15=TRUE, H2:H11>=90, H2:H11^0), IF(I15=TRUE, I2:I11>=90, I2:I11^0), IF(J15=TRUE, J2:J11>=90, J2:J11^0), IF(K15=TRUE, K2:K11>=90, K2:K11^0))
The first argument of FILTER tells the function what to filter (in this case A2:K11).
After that, an IF statement is set up to check each checkbox. If the checkbox is checked, the FILTER will only include students who obtained a 90 or higher in that subject.
If the checkbox is NOT checked, then the student is automatically included (that's the part that says "B2:B11^0" etc., since anything to the zero-power equals 1, and 1 and TRUE are the same to Google Sheets). In other words, if no checkboxes were checked, then all students would read TRUE for all subjects, i.e., all students would be included (or, to think of it another way, no one is rules out). While the ^0 is not strictly necessary (i.e., any number other than zero is the same as TRUE), I think it's better formula practice and easier for others to understand if TRUE is represented either as TRUE or as 1.
I also set conditional formatting on A15:A, to bold the name as you had it. (The conditional formatting rule says, in English, "If anything is there, use bold.") You can see the rule by clicking anywhere in the range A15:A, then selecting Format > Conditional formatting from the menu and clicking the open the rule that appears in the window to the right of the screen.

Why 'ng-attr-' can't be used with attribute 'multiple'?

I'm trying to make a <select> behave with single or multiple selection depending on a condition. So far I have tried:
<select
ng-model="data.model"
ng-attr-multiple="{{myCondition ? '' : undefined}}">
(here's a plnkr I have been testing with https://plnkr.co/edit/ACKBMZSJc2MVSJaDBGMY?p=preview)
But it won't work. Even leaving ng-attr-multiple alone won't work. What am I missing here?
https://docs.angularjs.org/error/$compile/selmulti
Binding to the multiple attribute of select element is not supported
since switching between multiple and single mode changes the ngModel
object type from instance to array of instances which breaks the model
semantics.
If you need to use different types of select elements in your template
based on some variable, please use ngIf or ngSwitch directives to
select one of them to be used at runtime.

Displaying and intrepreting tab layouts

I would like to know if it is possible to 'see' and display the following tab layout maybe through the Attribute Editor etc?
Or how can I interpret it?
In the following, I selected the shader - ShaderParam_resGen_srf01 but after searching through every attributes I can find in the Attribute Editor, I can neither find the CachedLayouts or the ShaderParamTabDepth elements.
Any ideas?
tabLayout -e -selectTabIndex 1"MayaWindow|MainAttributeEditorLayout|formLayout2|AEmenuBarLayout|AErootLayout|AEStackLayout|AErootLayoutPane|AEbaseFormLayout|AEcontrolFormLayout|AttrEdrexShaderSrfFormLayout|scrollLayout121|columnLayout971|frameLayout522|columnLayout976|columnLayout977|MW_ShaderParam_CachedLayouts|MW_ShaderParam_resGen_srf01|ShaderParamTabDepth0";
tabLayout is a UI element, not part of your scene.
From the documentation, this command is selecting the first tab of the specified tab layout control.
The long string is the "path" to the control:
MayaWindow
MainAttributeEditorLayout
formLayout2
AEmenuBarLayout
AErootLayout
AEStackLayout
AErootLayoutPane
AEbaseFormLayout
AEcontrolFormLayout
AttrEdrexShaderSrfFormLayout
scrollLayout121
columnLayout971
frameLayout522
columnLayout976
columnLayout977
MW_ShaderParam_CachedLayouts
MW_ShaderParam_resGen_srf01
ShaderParamTabDepth0
Depending on what you intend by "interpreting tab layouts," other commands listed in the documentation linked above should help you collect the specific information you need. If there's a particular aspect of the layout you want to query, be sure to specify that in your question.

Only allowing one Drilldown in SSRS

It took me hours of searching and putting together piecemeal parts to find the solution to this, so I figured I'd post it on here in the hopes of helping someone else.
The Problem: We need to display a report, with proper grouping and drilldowns. However, we should only allow one group to be drilled down at one time.
SSRS doesn't exactly have robust scripting options - for instance, you can't close other groups "on click" or anything like that. So how do you do it?
In My example i'm using the AdventureworksDW database. I want to have a dataset that includes the total sales for each group and region. My Stored Procedure looks something like this:
SELECT dst.SalesTerritoryGroup,
dst.SalesTerritoryRegion,
SUM(fis.SalesAmount) AS SaleTotal,
DATEPART(YEAR,fis.OrderDate) AS OrderYear
FROM [dbo].FactInternetSales AS fis
INNER JOIN [dbo].DimSalesTerritory AS dst
ON fis.SalesTerritoryKey = dst.SalesTerritoryKey
WHERE fis.OrderDate < #QueryEndDate
GROUP BY
dst.SalesTerritoryGroup,
dst.SalesTerritoryRegion,
DATEPART(YEAR,fis.OrderDate)
UNION ALL /*The ResellerSales table. Same info.*/
From there I added a table with two groups: SalesTerritoryRegion and its parent, SalesTerritoryGroup. I also added a column to the left INSIDE the SalesTerritoryGroup, with an X (this can also be an image if you'd like). This is the "Drilldown" button that we'll use.
Create a string parameter, mine was #ExpandedGroup. Set the Default to an empty string (so that all the groups start out collapsed). Right click on the SalesTerritoryRegion group, or whatever your subgroup is, and go to the visibility tab. Click "Show or Hide based on Expression" and enter something like this:
=iif(Parameters!ExpandedGroup.Value="" or
Fields!SalesTerritoryGroup.Value<>Parameters!ExpandedGroup.Value,True,False)
This statement means: If we haven't opened a dropdown, or if the dropdown isn't the one selected, set hidden to true. Otherwise, false.
Next click on your "X" column to the left of SalesTerritoryGroup or your supergroup. Right click to go to Textbox Properties. Click the action tab. From there select "Go to Report". When you specify a report, make the target itself (For instance, mine is Main). Then, add parameters to the report.
The most important here is ExpandedGroup. The name should be ExpandedGroup, but the value is not just [ExpandedGroup]. Instead, it's an expression:
=IIF(Fields!SalesTerritoryGroup.Value=Parameters!ExpandedGroup.Value,
"",
Fields!SalesTerritoryGroup.Value)
This expression says: If the Group is the same as the Expanded group, make ExpandedGroup an empty string when you load the report. Otherwise, send the TerritoryGroup value. Essentially, this will let us toggle on and off the drilldown (same as you would in the report if you had traditional drilldowns).
Note: Also be sure to pass other parameters! For instance, my query requires a date to exclude some transaction data. If you don't pass this parameter in the "Go to Report" action, then you'll have to enter it again when you DrillDown. This also means you can give yourself even more flexibility when you click a drilldown (changing a chart that's displayed etc.) which is what I'm doing for this project.
Hope it helps someone out! Of course, if there is a more elegant or simpler solution I'd absolutely love to hear it.