composeTestRule checking that atleast 1 item exists - kotlin

I have a list which has 2 different items. However, if the user gets close to the end of the list then the 2 same items are added again and again to create an infinite scrolling feel.
I've created a test to basically verify that the item exists like so:
composeTestRule
.onAllNodesWithContentDescription("Home")
.assertCountEquals(2)
As you can see this just finds nodes with the content description of "Home" and checks if their are 2.
Currently, this works as the screen size is small but let's say the screen size is doubled then this will fail as the assertCountEquals(2) would need to check for 4.
I was wondering to make this code better, is there a way to basically check that atleast 1 exists?

onAllNodes methods return an array, grab the first element and check whether it exists or is displayed.
composeTestRule
.onAllNodesWithContentDescription("Home")
.onFirst().assertExists()

Related

Carouselview: If only one item in view, items is shown indefinatley

So a carouselview is awesome for showing multiple elements. But once ther eis only one element in the view and the element isnt as large as the whole screen is, the result is:
Result
So I would need to make sure that if only one element is inside the view, it isnt repeated.
How can I set this or work around this issue without making two layouts and making only one visible, depending on how many items there are in the view?
Its quite simple. If the list contains only 1 item, just set the peek area to 0, otherwise to whatever value you wanT:
if (contentOfListView.Count == 1)
carousel_myAds.PeekAreaInsets = 0;
else if (contentOfListView.Count == 2)
carousel_mySales.PeekAreaInsets = Constants.PEEKAREINSETSHALF;
else
carousel_myAds.PeekAreaInsets = Constants.PEEKAREINSETS;

Apex, Dynamic action, Confirm action, not picking up correct text - what am I missing?

I'm obviously missing something and hoping someone might be able to help.
I've an Interactive Grid, and a button.
When the button is pressed the dynamic action on the button has 2 steps.
Action 1 - Execute Javascript to take a value from one of the IG cells and put it into a page item.
Action 2 - Confirm Action - Are you sure you wish to delete &P10_JOB_ID.
I've made the page item, &P10_JOB_ID, visible and I can see the value has correctly been changed to the value from the IG.
I write P10_JOB_ID into a database table - I get the correct value
But the confirm message isn't picking up the correct value from P10_JOB_ID.
Namely it uses the value in P10_JOB_ID when the page starts, but then as I move around the IG pressing the button and changing the value of P10_JOB_ID, the text in the confirm message never changes.
Can anyone suggest what I might have missed, I'm baffled.
Thanks a lot
Substitutions like &P10_JOB_ID. are made when the page is rendered, not dynamically, so reflect the value at time of page load.
You will need to use Javascript to perform the conform action, something like:
apex.page.confirm ('Are you sure you wish to delete ' + $v('P10_JOB_ID') + '?', 'DELETE');
$v is an APEX Javascript function that returns the current value of a page item.
I used 'DELETE' as an example of a request value; you may want to do something different here.
Ok - having the setting of value and confirm as 2 separate actions is what causes the problem.
As per fac586
That is the expected behaviour. Static text substitutions are performed once during page show processing. They are not evaluated dynamically in the browser at runtime as values change.
Drop the second action and extend the first to display the confirm dialog using the apex.message.confirm JS API method, accessing the item value using the $v shorthand method.

How to wait untill drop down values load in if else condition in robot framework

My scenarios are: I have two drop down values side by side if the first drop down-selected based on the value selected second drop-down values will be loaded from that we need to pick one value. in one case from the first drop down if I select unknown or any legal purpose I should not go for the second dropdown. this is what the requirement I have please help me out. Below is the code I have written
Variables
${var1}= Unknown
${var2}= Any legal purpose
The user selects random NAICS code and subcode from the drop-down
${selectedNAICScode}= User selects NAICS code from the drop down
${NAICS_code} run keyword if
${selectedNAICScode}!=${var1} or ${selectedNAICScode}!=${var2} run keywords
... element should be visible xpath://select[#id="ddlNAICSSubCode"]
# ... is visible ${NAICS_subcode}
... User selects NAICS-sub code from the drop down
... ELSE run keywords
... element should not be visible xpath://select[#id='ddlNAICSSubCode']
Even though we are giving one argument when I run the script it is saying expecting 1 to 2 arguments but got 0. my question is how we can wait until the drop-down values load into the drop-down in else condition.
You can use the following functionality:
WebDriverWait wait = new WebDriverWait(driver, INSERT_INTEGER_WAITING_TIME);
boolean waitUntil = wait.until(ExpectedConditions.invisibilityOfElementLocated(By.xpath("ENTER_YOUR_XPATH_OR_OTHER_ATTRIBUTE")));
In this way, your action will happen only when the element is going to be visible.
If you need further information check this link

For loop on test case titles in robot frame work

On one page there are various item. I am able to iterate over all items/elements on the page.
Though would like to keep every iteration is a separate test cases.
As in below Test case title First Page Item No expand
Is there any way to put test case name in for loop.
For example First Page and Item No both can be variable and controlled by for loop.
*** Test Cases ***
First Page Item No expand
: FOR ${INDEX} IN RANGE 1 80
\ Click Element xpath=/html/body/div[1]/div[2]/section/div/div[2]/div[2]/div[${INDEX}]/div[1]/div/p[2]
From my understanding this should not be possible. However there are two ways to get around:
Treat is as one test case, have a keyword that does the FOR loop
Have 80 test cases calling one keyword with an ${index} attribute

Does mvc 4 application need another model to return aggregate data on an existing table and model

I have a table (and model) with the following properties in an asp.net MVC 4 application:
TV Table
height
width
depth
type
brand
cost
When the user answes a question about the space that they have for the TV I then do an ajax call to determine which types are possible to fit into the space they have specified. Which type of TV type they want is the following question, so some options may need to be disabled. The SQL for what types fit in the space is "select distinct type from TV where height < #height and width < #width and depth < #depth".
Should I:
1. create a new model that I call from the TV controller just to return the distinct types
2. add a method to the TV model that I call from the TV controller that just returns a list of string with the types that fit
Depends on what you want to display to the user based on her selection' e. g.
If you want to display TV name + its description then returning a list of TV model will make sense.
If you are just going to display a list of TV names in combo box, then returning a list of string will suffice.
Calling a new action make sense in both cases IMHO.
EDIT:
For 2 - I want to return a list of string - should I create a new data model for this, or add a method in the existing TV data model that returns a list of string?
To expand on above query, since its not clear (at least I do not visualize it) from your question i will assume few things.
Case 1: You are displaying a view say "TVSelection" to the user that does not contain list of TVModels. In this view you are expecting user to enter three values i.e. Width, Height, Depth. Now when user enter these values, she can submit the form or you can fetch the TV Brand name list on Lost Focus event as well. In any case, the question would be are you updating existing view by populating the combo box or you are displaying a new view. I am assuming you are updating existing "TVSelection" view by the means of making an AJAX call. In that case you can just call a method on your controller (which displayed the "TVSelection" view) that returns a list of TV Brand names.
Case 2: You are displaying "TVSelection" view that already has a list of TVModel objects and you update it dynamically on selection of required field (filtering). In this case you can add a method in the TVModel itself to filter names only that matches the user selection.
I found these links relevant 1 & 2.
Hope that make sense.
Please add more details to your question if this does not answer your question.