Selenide ElementsCollection throwing StaleElementException - java

I've started using Selenide recently, and I'm loving the fluent code it allows.
I do have strange issue with ElementsCollection, however.
$$("some ref").filterBy(not(attribute("an-attr-that-should-not-be"))).getTexts()
This query intermittently returns stringified StaleElementReferenceExceptions, and I can't understand why.
If I run the query in the debugger, it returns valid values, while during normal runtime (single thread application), this is what I get.
The target element is a GWT combo box results list.
Could someone please point me in the right direction?
Update: if it's relevant, I'm using InternetExplorerDriver.

Chrome and ChromeDriver specifically fire off StaleElementReferenceException like its the point of your test - any time an element is no longer visible the WebElement reference you have to it becomes invalid and you must look it up again. If the combo is showing/hiding or changing those could cause this (need more details on which combo and what seems to cause it for more specific) - try looking up the element when you expect to use it instead of reusing the reference again and again.

Found the problem. Apparently, the Selenide ElementsCollection cached a previous version of the element list, which updated a lot slower than anticipated, and was trying to access this ghost data when retrieving texts.
Fixed by using $$ where the list is iterated, instead of the usual static constants in class header.

My solution for this problem was very simple and straight. I just set the timeout for the search of an element around 10 seconds and it worked. It can be done only with one string:
Configuration.timeout=10000
The value is in milliseconds, of course.

Related

Eclipse Java auto complete changes exact matches to substring matches

I recently got a new computer, and installed Eclipse 2018-12 (4.10.0)
Since I installed it, auto complete for Java has been showing results in the wrong order. It puts substring matches before exact matches. If, for example, I'm calling the stream() method on a list, I'd type "myList.stream()". The suggestions will show stream() at the bottom of the list, and parallelStream() at the top. Since the default behavior is to replace what you typed with the top result, stream() gets replaced with parallelStream() when I continue typing. The same thing happens on Maps. When I'm trying to use put(), it replaces it with .compute(). On Streams, map() gets replaced with flatMap() as well.
Example of the suggestions for stream()
I've looked all over for a setting to change this, but have yet to even find someone else with this issue. Any help would be appreciated.
If it's useful, I'm on Windows 10.
Well, I feel silly answering my own question minutes after posting it, but I just figured out how to fix it, so here goes.
Load Preferences, then navigate to Java->Editor->Content Assist->Advanced. Check the Java Proposals check box.
I'm not that familiar with the different proposal types in these settings, but turning that one on fixed the problem.
Java->Editor->Content Assist,
uncheck "show substring matches" in section "Sorting and Filtering"

How to Locate a Dynamically Changing Element in Selenium

I'm trying to click on an element that stays roughly the same but changes a bit with each page refresh. For example, sometimes the CSS value will be #pmts-id-49-announce sometimes it will be #pmts-id-44-announce and sometimes another number. The issue is I cannot know in advance what number it will be (it could be anything).
I understand to resolve this specific issue I could use #contains method in XPath but the real issue is there is another element which changes in the same way and it would be impossible to know which is which. In other words, sometimes the element I'm looking for will be 44 but sometimes the other element will be the one which is 44 - it's impossible to know beforehand which element will get which number.
How can I locate such an element in this circumstance?
I'm using Java, Selenium, XPath/CSS.
Thanks

How to refresh jsp page?

I'm new to Google App Engine and I'm having a little problem that I can't seem to be able to find the solution to.
Whenever I create/delete/update something from the Datastore, in the end I do this:
resp.sendRedirect("/view_list.jsp");
And the page doesn't get updated.
For instance, if I have a page with a list of 2 items, then I create another item and I redirect to that page with the list, and instead of showing 3 items, it shows 2 items, until I change page and come back.
So how can I make sure that the page refreshes after my changes to the Datastore?
A couple of points that are relevant:
The Data store is HRD (High Replication Database) and as per the documentation, the delay from the time a write is committed until it becomes visible in all datacenters means that queries across multiple entity groups (non-ancestor queries) can only guarantee eventually consistent results. Consequently, the results of such queries may sometimes fail to reflect recent changes to the underlying data. Please refer to the documentation for more details.
In short, to get consistent reads, use get as much as you can. If you use a query, there could be a delay due to the indexing.
Hope this helps. I also suggest to frame the question title better. The question is a good one but could get lost when it says "refresh the jsp page".

Find and delete duplicates in a Lotus Notes database

I am very new to lotus notes. Recently my team mates were facing a problem regarding the Duplicates in Lotus notes as shown below in the CASE A and CASE B.
So we bought a app named scanEZ (Link About scanEX). Using this tool we can remove the first occurrence or the second occurrence. As in the case A and Case B the second items are considered as redundant because they do not have child. So we can remove all the second item as given below and thus removing the duplicates.
But in the Case 3 the order gets changed, the child item comes first and the Parent items comes second so i am unable to use the scanEX app.
Is there any other better way or software or script to accomplish my task. As I am new to this field I have not idea. Kindly help me.
Thanks in advance.
Probably the easiest way to approach this would be to force the view to always display documents with children first. That way the tool you have purchased will behave consistently for you. You would do this by adding a hidden sorted column to the right of the column that that you have circled. The formula in this column would be #DocChildren, and the sort options for the column would be set to 'Descending'. (Note that if you are uncomfortable making changes in this view, you can make a copy of it, make your changes in the copy, and run ScanEZ against the copy as well. You can also do all of this in a local replica of the database, and only replicate it back to the server when you are satisified that you have the right results.)
The other way would be to write your own code in LotusScript or Java, using the Notes classes. There are many different ways that you could write that code,
I agree with Richard's answer. If you want more details on how to go thru the document collection you could isolate the documents into a view that shows only the duplicates. Then write an agent to look at the UNID of the document, date modified and other such data elements to insure that you are getting the last updated document. I would add a field to the document as in FLAG='keep'. Then delete documents that don't have your flag in the document with a second agent. If you take this approach you can often use the same agents in other databases.
Since you are new to Notes keep in mind that Notes is a document database. There are several different conflicts like save conflicts or replication conflicts. Also you need to look at database settings on how duplicates can be handled. I would read up on these topics just so you can explain it to your co-workers/project manager.
Eventually in your heavily travelled databases you might be able to automate this process after you work down the source of the duplicates.
These are clearly not duplicates.
The definition of duplicate is that they are identical and so it does not matter which one is kept and which one is removed. To you, the fact that one has children makes it more important, which means that they are not pure duplicates.
What you have not stated is what you want to do if multiple documents with similar dates/subjects have children (a case D if you will).
To me this appears as three separate problems.
The first problem is to sort out the cases where more than one
document in a set has children.
Then sort out the cases where only one document in a set has children.
Then sort out the cases where none of the documents in a set has children.
The approach in each case will be different. The article from Ytira only really covers the last of these cases.

Solr Geospatial Search return wrong distances

I'm using the Solr 3.6.1 Webapp with the SOLR-2155 Patch for geohash field support.
I set everything up like described here: https://github.com/dsmiley/SOLR-2155
Now and then the search returns a totally false distance for every hit. Refreshing the result won't help. If I change the offset of the search (e.g. listing the 2nd page) it's all fine again. Even going back to the first page now shows up the right distance.
It's not the webapp because the json stream I get directly from Solr contains the same distances as result score. In my case it's always 20015,12km.
Here is my Query:
fq={!geofilt}
&fl=internalid,score
&start=0
&rows=10
&sort=geodist()+asc
&sfield=location
&pt=53.6,10.11
&d=50
&q={!func}geodist()
I wrote SOLR-2155. I'm not particularly happy with the distance sorting code therein; there seems to be something I overlooked. It shouldn't be some sort of math issue, it's some sort of Lucene internals issue, I think. If you have just one point per document, then use solr.LatLonType. If you have multiple then.... :-( I don't know what the problem is. In Solr 4, the replacement code for this called SpatialRecursivePrefixTreeFieldType and it uses different code but it is similar, so I'm not sure if the problem will go away or not. But even in that case, again, I'm not at all happy with the implementation. I know how I want to do it right, but it's not on the top of my TODO list right now.
BTW, you are basically reporting a bug, and the proper place to report a bug would be the issue tracker of the project in question -- in this case, that's GitHub SOLR-2155. StackOverflow doesn't make sense for that.

Categories