I've got a CategorySearch box in my header that passes the selected value to a search results page via query params. It works great the first time.
But I want the header (w/ search box) to remain on the results page and allow users to change the search terms from the header. However if you change the search term in the header, the results page components won't re-render with the new query params even through the route changes.
If you change the second CategorySearch component on the results page, it does update. I plan on hiding this component once this is working.
I know I'm missing one piece to keep the components in sync. Any ideas?
Header component
<CategorySearch
componentId="q"
categoryField="_type"
URLParams
onValueSelected={val => this.props.router.push(`/search?q="${val}"`)}
...
/>
Results Page
<CategorySearch
componentId="q"
URLParams
categoryField="_type"
/>
<ResultList
componentId="result"
dataField="title"
pagination={true}
URLParams
react={{
and: [
'q',
],
}}
onData={this.renderData}
/>
You can see in this example below, I first ran the search "test" from the homepage which landed me on the results page with the correct "test" search results. But then I changed my search query in the header to "yoga" and pressed enter. It changed the route but the search results still show for "test".
Example: https://i.stack.imgur.com/VEmLz.gif
Thanks in advance for the help!
Removing the URLParams from both CategorySearch and ResultList help me.
Hope this will help you too !
Related
I am experimenting with AppiumLibrary in RobotFramework and have a simple test for a requirement that states: "the Set button should exist on this page.". I am testing this by retrieving the button that has a specified ID and then checking if that button has the right text.
I am able to retrieve the button I want via ID however am having trouble getting the actual text on the button.
Here is how the button is defined on the web page:
<button id="button-set" class="button ng-binding" style="width: 20%">Set</button>
Very simple! Using Appium Desktop in web/hybrid app mode and clicking on the Set button it says the "text" attribute shows "Set". However I've learned that using the attributes in Appium Desktop arent valid when searching for elements on a webpage, for example searching by the Class attribute in Appium Desktop (android.widget.Button) is not correct because on the web page the class for the button is instead: "button ng-binding".
I have tried the following:
# this retrieves the button fine, by ID
PAGE SHOULD CONTAIN ELEMENT xpath=//button[#id="button-set"]
# these all return 'None'
${name}= GET ELEMENT ATTRIBUTE xpath=//button[#id="button-set"] name
${text}= GET ELEMENT ATTRIBUTE xpath=//button[#id="button-Set"] text
So, I am unsure which Attribute to use to retrieve the text when retrieving element by ID. Instead, I have tried to retrieve the element this way:
# this also passes fine - I feel like I should also make sure this button has the correct ID, to make the mapping
# between test procedures and cases easier, but if this is as good as it gets then
# this can be argued for
PAGE SHOULD CONTAIN ELEMENT xpath=//button[contains(text(),'set')]
# however, the following does not make sense, this returns "button" instead of "button-set", which makes me think the xpath query is not correct
${id2}= GET ELEMENT ATTRIBUTE xpath=//button[contains(text(),'set')] id
# again, both of these return 'None'
${name2}= GET ELEMENT ATTRIBUTE xpath=//button[contains(text(),'set')] name
${text2}= GET ELEMENT ATTRIBUTE xpath=//button[contains(text(),'set')] text
I have also tried the following:
${element}= GET WEBELEMENT xpath=//button[#id="button-set"]
# this returns "button-set" as you'd expect:
${id3}= GET ELEMENT ATTRIBUTE ${element} id
# these again return 'None'
${name3}= GET ELEMENT ATTRIBUTE ${element} name
${text3}= GET ELEMENT ATTRIBUTE ${element} text
I feel like this should be a very simple thing to do, and can see in other questions that you would use the Name attribute when using pure Appium. However, using the Robot Framework library instead, that these doesn't appear to be the right approach. I must be doing something pretty simple wrong here, can anyone point it out?
Thank you!
Stumbling across the same issue when trying to fetch element's attributes via Get Element Attribute keyword. It seems that when fetching for the element's text, your best bet is to use Get Text keyword. Switching to Get Text keyword solved the problem on my case. Please see the links below for further details. Spoiler: there aren't any real explanations as to why the Get Element Attribute is flaky.
https://serhatbolsu.github.io/robotframework-appiumlibrary/AppiumLibrary.html#Get%20Text
https://github.com/serhatbolsu/robotframework-appiumlibrary/issues/98
I need to change page title dynamically with tag manager, it must be like the search query from google.
For example if I search in Google (organic and paid): Hotel Toronto
And the title must be: Hotel Toronto
Do you have any idea on how I can do it?
Thanks in advance!
You can change the page title by creating a custom HTML tag and set the title property
<script>
document.title = "I am title hear me roar";
</script>
Set the trigger to "Pageview->All Pageviews".
However I doubt that even with the latest changes in the way Google evaluates javascript in pages it will evaluate a title that's been changed via Javascript. That does need to stop you from trying, but the chances of success are slim.
I have a page that is a report from a database and I'm working on modifying how the filtering works. The intention is to allow the user to select possible values form a list that will be used to filter the resulting report. There are too many values to do this with checkboxes. I'm defining a multiple selection list box with this:
<g:select name="country" from="${countryDataList.KOUNTRY}" value="${params.country}" multiple="true" />
countryDataList is a List<> of objects with a name and a value which I create in the controller. I'm able to get the selected counties and process them without an issue.
But when the page returns from the controller with the filtered report, only the first selection in the list is selected. It doesn't re-select all of the items that the user selected. I am passing the params.country object back from the controller as
country:params.country
I saw some posts about this not working, but they are all from several years ago. Am I missing a vital step?
Ahh sorry, I was reading it on the phone initially and missed the point.
So what you want is a way of sending a multiple select box to a confirmation page. If I understand correctly?
Anyways how many objects in the select are we talking massive or a dozen couple of dozen or so ?
What I did was use check boxes and did a confirmation which shows the selection ticked in check boxes.. So this is the confirmation page that loads in https://github.com/vahidhedayati/mailinglist/blob/master/grails-app/views/mailingListEmail/confirmcontact.gsp
this page which is where multiple attachments selected from the schedule re-appear...
https://github.com/vahidhedayati/mailinglist/blob/master/grails-app/views/mailingListAttachments/_mailerAttachmentsDisplay.gsp.
Please note advice below is all conceptual stuff and there may be easier ways than this
Other than that You could create a taglib call on the confirmation page https://github.com/vahidhedayati/ajaxdependancyselection/blob/master/grails-app/taglib/ajaxdependancyselection/AutoCompleteTagLib.groovy#L55 which takes in your arrayList you could probably convert it to JSON pass it into the javascript that you load in within the taglib (on mine further down it loads this page in)
https://github.com/vahidhedayati/ajaxdependancyselection/blob/master/grails-app/views/autoComplete/_selectJs1.gsp#L23
and look to reselect them using javascript... as I say I haven't tested the last bit, the first bit i.e. checkbox works it is/has been in use.
Years later from you I just had the same problem. What I figured out is: it happens when params.country is an array instead of a Collection (i.e. an ArrayList).
A workaround for this if you want to stick to the array type is at the value attribute of the tag doing this: params.country?.findAll().
I have made an app with jQuery mobile and laravel.
On the first page "mobilepage1" if have a form with a next button.
Also some of the form elements are dropdown menu's. The dropdown select options I get from a table in the database.
In the form on mobilepage1 I have a dropdown list with all department names:
I get this list from my controller like so:
$departmentlist = Company::find($usercompanyid)->departments;
This is how I display the list in the mobilepage1 form:
{{ Form::label('department', 'Department:')}}
<?php
foreach($afdelingslijst as $item) {
$afdelingsarray[$item->afdelingen] = $item->afdelingen;
}
?>
{{Form::select('size',$afdelingsarray)}}
On the second page I want to make a back button.
I tried the jQuery mobile way with a link with: data-rel="back"
But this does not work. I get a page error, it's missing the departmentlist used in mobilepage1. I can make a link to a route to mobilepage1, but I think all the information the user entered in mobilepage1 would be gone.
I see this url in the address bar when I am on mobilepage2 (this is after I filled in the form on mobilepage1 and clicked next).
/public/mobilepage2?size=Personeelszaken&size=32&directechef=Tineke&size=1&size=1&size=1&date-2=&size=1&time=&omschrijving=
Is there a way I can link to the the mobilepage1 route and still keep the information the user entered?
It looks like it would work just by hitting the back button if you passed in the department list with a view composer rather than through a route. Remove it from your route and place this in a file that's being autoloaded...
View::composer('mobilepage2', function($view)
{
$departmentlist = Company::find($usercompanyid)->departments()->lists('afdelingen','afdelingen');
$view->with('departmentlist', $departmentlist);
});
I'm not sure how you are finding $usercompanyid but you should be able to find it within the closure or pass it in by adding use ($usercompanyid) right after the function($view) part.
Also using the lists() function like that will build your array for you so you don't need to worry about the foreach loop in your view.
Since the values are getting passed back and forth as get variables, I think if you use Form::model() instead of Form::open(), it should place all those values back into the input fields for you.
New to Struts2.
I have a search criteria form(search1) ,where I have dropdown lists to submit to get a result page (consolidatedreports.jsp).
In my result page, I am showing the data from the search criteria, but I also have a form at the top of the results page with search2 criteria to submit again.
I am chaining my actions because the heading for the results page needs a value from the search1 criteria to determine a heading value.
This works
Question
Now I want the heading to change when I use the search2 form in the results page.
How can I use the values from the search criteria in the search1 and override search2 values in the results page when a user chooses new criteria to run a new report on the results page?
I am modifying someone's code so it has to be done like this.
Can someone suggest a link so I get some information?
please clarify your question...
Using the search criteria and the value which you have entered in your first search page go to your action class.
There you have to check what are your search criteria.
Based on the criteria your codes for selecting values will be get differentiated.
That is you have to use if else if or some switch for each case according to your criteria.
Then in each case you have to bind your values into a list(if it is a server side coding.) and return the control to forwarding 2nd search page.
If it is a client side coding, you just need to return to 2nd page.
In the second page at top you can put your search boxes as in 1st page. then you can get the values from the list and print them, if its server side coding.
If its client side coding, get the selection value for criteria from action page , find the results using your calculations. print it..
the same action class can be used for your second page's search field also..
while submitting the form, keep a hidden field which will specify the name of your page, so that we can identify which search criteria is printing result, using that value you will be able to change your header values also.