Check whether SelectBox has items, Robot-Framework, Selenium2Library - selenium-webdriver

How can I check whether a <select> box has more than 1 <option>?
The <option>s are loaded using ajax and are placed into two <optgroup>s.
<option value="">default</option>
<optgroup ...>
<option value=..>...
<option ..>...
...
</optgroup>
<optgroup ...>
<option ..>...
<option ..>...
...

You can use Get List Items which will return a list of all items and then use Get Length to get the number of elements in the list:
Select Options Test
Open Browser your_url chrome
#{items} Get List Items id=select_list_id
${list_length} Get Length ${items}
Should Be True ${list_length} > 1

You have at least a couple of choices:
use the Get Matching Xpath Count keyword to return the number elements that match an xpath which represents the options, or
Use Get List Items to fetch all of the items, then use Get Length to return the length.
Since I can't write an example against your exact code, the following example runs against the page at http://the-internet.herokuapp.com/dropdown. It has markup that includes this (at the time I write this answer):
<select id='dropdown'>
<option value="" disabled="disabled" selected="selected">Please select an option</option>
<option value="1">Option 1</option>
<option value="2">Option 2</option>
</select>
Here is a complete working example:
*** Test Cases ***
| Example
| |
| | Go to | ${ROOT}/dropdown
| |
| | ${count}= | Get matching xpath count | //select[#id='dropdown']/option
| | Should be equal as numbers | ${count} | 3
| |
| | #{items}= | Get list items | //select[#id='dropdown']
| | ${item count}= | Get Length | ${items}
| | Should be equal as numbers | ${item count} | 3
*** Settings ***
| Library | Selenium2Library
| Suite Setup | Open browser | ${ROOT} | ${BROWSER}
| Suite Teardown | Close all browsers
*** Variables ***
| ${BROWSER} | chrome
| ${ROOT} | http://the-internet.herokuapp.com

Related

Mark cells that contain words from a FILTER list

I have a list of words in a basket which I want to pre-select through a FILTER list and color code the words in the basket which appear in the FILTER sheet. The challenge is, that the words in the basket have not the same word, but rather contain it. Here an example >
FILTER:
+--------+
| Apple |
+--------+
| Banana |
+--------+
Basket:
+--------------+---+
| Apple//Cake | x |
+--------------+---+
| Water | |
+--------------+---+
| Coke bottle | |
+--------------+---+
| Banana split | x |
+--------------+---+
use:
=(A2<>"")*(INDEX(REGEXMATCH(LOWER(A2),
TEXTJOIN("|", 1, LOWER(INDIRECT("FILTER!A:A"))))))
You can use the following formula as a rule in Conditional formatting
=REGEXMATCH(A2,""&JOIN("|",INDIRECT("'FILTER'!A1:A3"))&"")

Extracting actions from child component to parent

I've been trying to build a react based application, and I am stumped with how to solve this situation:
Let's say I have a component called "SimpleTable" that provides as the name says, a simple table - the props for it are "headers" (array), "rows" (array) and "paginated" (bool)
If the paginated is false, then we just give a simple long table - if it is true, we chunk the rows to multiple small tables, and provide buttons to toggle prev/next - so far so simple.
Now comes the challenging part - I want to sometimes have the table as just a table in my code, and sometimes I want to wrap it in a "card" element. I have introduced a new prop to the component called "asCard" (bool), which changes the output of the HTML, and changes where the prev/next buttons are placed.
Is there a way to reverse this, so that instead of having "asCard" in my component, I would have a wrapper component that I can put anything in, and it can "extract" actions from the child component, and place them in a different position - this way I could have many different components, and would not have to worry about having "asCard" on each of them.
What I am thinking is maybe having a "Card" component, and have a function in it called something like "extractAction", and then it passes it to the child component, and the child component then has a check for a prop called "handleExtractAction" which then passes the action element to, instead of using it in its own output. But I am not sure if this is an overly complicated way of doing this, and if there is a more sensible way of doing it.
EDIT:
I'll try and add a visual example of what I am talking about
SimpleTable with pagination:
< >
item 1
------
item 2
------
item 3
------
item 4
------
item 5
------
SimpleTable inside a Card, with basic parent>child setup:
------------------------
| card title |
------------------------
| |
| < > |
| |
| item 1 |
| ------ |
| |
| item 2 |
| ------ |
| |
| item 3 |
| ------ |
| |
| item 4 |
| ------ |
| |
| item 5 |
| ------ |
------------------------
And the result that I would want to have instead, without having to use "asCard" in each custom component I create.
------------------------
| card title < >|
------------------------
| |
| item 1 |
| ------ |
| |
| item 2 |
| ------ |
| |
| item 3 |
| ------ |
| |
| item 4 |
| ------ |
| |
| item 5 |
| ------ |
------------------------

Remove duplicates in Tableau

I am trying to remove duplicates from the ID field, I would like it so that only the earliest retention academic period is associated with the unique ID. For example:
Status | ID | Profile Period | Retention Period | Academic Period
Retained | 654321 | 200610 | 200620 | 200620
Retained | 654321 | 200610 | 200710 | 200710
Retained | 654321 | 200610 | 200720 | 200720
CODO IN | 123456 | 200510 | 200520 | 200520
CODO IN | 123456 | 200510 | 200610 | 200610
CODO IN | 123456 | 200510 | 200620 | 200620
So what I want is to keep the repeated terms for Retained IDs, however, I want to the repeated CODO In values to take the earliest retention period:
Retained | 654321 | 200610 | 200620 | 200620
Retained | 654321 | 200610 | 200710 | 200710
Retained | 654321 | 200610 | 200720 | 200720
CODO IN | 234567 | 200510 | 200520 | 200520
I have tried {Fixed [ID]: MIN [Retention Period]} but it doesn't seem to remove all the repeats for CODO In (i.e. I still see the counts for 200610 and 200620).
Any suggestions on how to approach this task?
As other commenters have mentioned this work is usually best dealt with before the data is inputted into Tableau. This is because if this data is not required to be visualised it is best practise to remove it to keep the dashboard performant and simple.
However, if you require a solution in Tableau you were on the right track with a LOD. If you nest it with an IF statement so that only the CODO Status duplicates are remove you should get your desired result.
So create the following as a calculated field:
iif([Status]='CODO IN',
[Retention Period] = {Fixed [ID]: MIN([Retention Period])}
, TRUE)
Then if you drag this calculated field to the filters shelf and select 'TRUE' you will then remove the duplicates.
Let me know how it goes.

Excel Formula, Sumifs, condition is an array range

Goal: Use SUMIFS to get the sum of value if color is Red or Yellow. Outcome should be 3.
+---+--------+-------+---+-----------+
| | A | B | C | D |
+---+--------+-------+---+-----------+
| 1 | Key | Value | | Condition |
| 2 | Red | 1 | | Red |
| 3 | Yellow | 2 | | Yellow |
| 4 | Green | 3 | | |
+---+--------+-------+---+-----------+
Problem:
It works if I hardcode the condition {"Red","Yellow"}. The result is 3.
=SUM(SUMIFS(B2:B4, A2:A4, {"Red","Yellow"}))
But if I reference the condition by cell D2:D3, I get 0.
=SUM(SUMIFS(B2:B4, A2:A4, D2:D3))
Question: How do I reference the condition dynamically by cell and make it work?
Use SUMPRODUCT() instead of SUM():
=SUMPRODUCT(SUMIFS(B2:B4,A2:A4,D2:D3))
One note:
This variation allows the expansion of the lists without the need to reapply the ranges:
=SUMPRODUCT(SUMIFS(B:B,A:A,D2:INDEX(D:D,MATCH("zzz",D:D))))
Alternatively, you can use SUMIF() together:
=SUMIF(A2:A4,"Red",B2:B4)+SUMIF(A2:A4,"Yellow",B2:B4)
Or make sure you're using CTRL+SHIFT+ENTER with your current formula attempt.

How to implement custom sort order with some items at fixed places in solr?

I have a list of drawers in a mysql table named Drawers like
| BOX | RANK |
|----------------|--------|
| Box1 | 1 |
| Box2 | 2 |
| Box3 | 3 |
| Box4 | 4 |
| Box5 | 5 |
Then I have another source which says some of these boxes contains jewel and should be placed at a specific position only(Lets call this table jewelboxes).
| BOX | RANK |
|----------------|--------|
| Box1 | 4 |
| Box3 | 1 |
| Box5 | 3 |
I have certain restrictions that needs to adhere to:
I cannot write a stored proc on these tables
I want to get a list of Boxes on Solr where position of the jewelboxes should be fixed irrespective of the calling order(ascending/descending). for example,
ascending order would be:
| BOX | RANK |
|----------------|--------|
| Box3 | 1 |
| Box2 | 2 |
| Box5 | 3 |
| Box1 | 4 |
| Box4 | 5 |
descending order would be:
| BOX | RANK |
|----------------|--------|
| Box3 | 1 |
| Box4 | 2 |
| Box5 | 3 |
| Box1 | 4 |
| Box2 | 5 |
I am importing these tables into solr from dih, and currently ripping my hair apart thinking about how to do this. I have 2 options in my mind, but both are not very clear, and would like you folks here to help me out. My options are:
Write a query in such a way that'll give me correct order. (this would need a master level querying skills because all we have is a select query in dih)
Write a CustomFieldComparator as described in the following link: http://sujitpal.blogspot.in/2011/05/custom-sorting-in-solr-using-external.html
Is there any third approach which can be followed to get the desired results ?
UPDATE:
I can work without the descending order criteria, but I still need the ascending one.
Thanks :-)
I would create a custom indexer in a language you are comfortable with (see https://wiki.apache.org/solr/IntegratingSolr - I work in Python and use mysolr) when you need more flexibility like this. Maybe create two fields, one for "ascending" and one for "descending"; make a list with the ranks, one with reverse ranks, then query the second source to use for overrides on both lists - or whatever you need to do to process the data. I guess the feasibility also depends on how many records you need to index. Then process each record, adding the information for the two ranking fields from the list, and send them to your Solr server in batches.

Resources