wierd behavior on Scrolling selenium - java

I'm working on ui automation and recently discovered one interesting behavior.
Sometimes I need to scroll to some particular element and I've been using both, JS function to scroll to element and actions.moveToElement(WebElement)
This seem to work for any checkboxes, textboxes, buttons types of elements, but when i need to move to the table cell () of the table which has multiple columns - see that table is being shift to the left, this happens almost every time. Let say there is a table 5x5 and i'm only looping over 5th column, when i do scroll2element via either of those 2 functions - the whole table is getting messed up. all the previous columns would disappear and my 5th column is shifting all the way to the left.
I found the workaround - instead of scrolling to specific table cell i scroll to the button that is located on top of that table, but just out of curiosity, if anyone experienced such an issue and what did they do? Thanks

I think you problem could be with selectors.
Try using CSS selectors over the XPath, from my life experience XPath doesnt work as well ass CSS.
Also i'm always using JS and never had any problems.
try that
WebElement x = driver.findElement(by);
((JavascriptExecutor) driver).executeScript(
"arguments[0].scrollIntoView();", x);

Related

Adding row to a ListGrid at a specified index Smart GWT

Currently I'm working on a listgrid which is editable and my requirement is to create a a new row every time a user selects a row and presses the "Create" Button. The new row needs to be added immediately below the selected row. I tried using the below method
ListGrid.getRecordList().addAt(ListGridRecord rec, Index index)
However I got the warning message
15:48:04.373:MUP3:WARN:Log:ResultSets are readonly. This operation (addAt) will be ignored.
I've searched the smartgwt showcase to look for ways to edit a grid , so that new row is added at a specified index, however I wasn't able to find anything suitable.
I got to know that ResultSets is getting created because I'm using the statement
ListGrid.fetchData() Is there any way to solve this issue? Any suggestion is highly appreciated!
Muchas Gracias.
Figured it out, quite a weird trick...but works for me...
what you need to do is use grid.setRecords(grid.getRecords()); just before grid.getRecordList().addAt(rec, index); I think doing this makes the ResultSet editable.

Java Selenium - How to interact with id-less/class-less element?

I'm trying to interact with a button on a page. Linktext and xpath do not work, there are no classes or combinations of selecting elements and looping through them I can find that work.
Here is the screen shot of the code I'm trying to do a .click()
Please help me how do i achieve the same ?
I think you have 2 options as below. I simplified your example HTML code to smoke test these queries:
Select an element based on its content. The drawback is of course that as soon as "Historical Scans" label changes to something else your query will stop working.
//nav[#id='secondaryNav']//ul[contains(#class, "menu")]//a[normalize-space(.)="Historical Scans"]
(working example on xpath tester http://xpather.com/dqZ7UWvz)
Select an element based on the position on the list. The downside is that it will stop working once this element changes its position.
//nav[#id='secondaryNav']//ul[contains(#class, "menu")]/li[3]/a
(http://xpather.com/rgexHKBB)
Based on my experience you should not rely on any other attributes or elements. Ideally, the best option would be to add ids/classes. Please let us know if this solves your problem.

Element in View port issue [Peculiar]

I am getting the following error in a peculiar fashion.
The point at which the driver is attempting to click on the element was not scrolled into the viewport.
The user story goes like this, if a selection is made in a check group, corresponding div with few fields will be enabled. Similarly for n-number of selection there will be n-number of DIVs. When i select only one option in the div, it works as expected but not for the multiple options.
i have read some stuffs and tried all the possible combination about the above said view port issue. My work around attempts and the outcomes are given below.
1) Tried with the Advanced interaction method. (Action class) - The same exception
2) Accessed with java-script executor- same exception
few more will be updated soon.
I have tried all the combination of locating mechanism. Everything works perfect and the element is in visible mode. But when i perform any operation on the second DIV values i am getting the above said exception.
what can be possibly done to get the element in working mode?
EDIT :
1.The DIV elements all are in view port and they all are accessible individually.
2. Div are enabled as per the check box selected
3.In a scenario, if we choose two check box, after a first selection you can edit the DIV and for the second selection the DIV will not be accessible.
4. both DIVs are identical with respect to the elements/attributes/properties of the elements.
5. When a Active div is edited no other div will be available in the UI.
For some reasons i was not able to produce the Reproducible code here.
i sorted out the problem. There was actually a frame for every DIV. these frames are just hidden after the edit and a fresh frame is opened every time, so when i access the second div i had to choose the latest frame.
i just polled for the number of frame and proceed with the latest one.

Combine javafx 2 ListView and GridPane features

My target is to display an abbreviation list with two entries per line: the abbreviation and the corresponding long version. For a nice layout I used a GridPane because of the vertical alignment over all entries - it's nice to read.
But I also want to scroll to the clicked abbreviation and set the focus on it like in a ListView version of it.
For example the # on page links in good old HTML. Is there another javafx layout element I miss to achieve this?
I don't believe there is a provided control that will work for the specific scenario you are describing. However, I think one of these options might work for you...
Use the TableView control and add two columns for the information you want to show (one for the abbreviation and another for the long version). TableViews also have the scrollTo and setFocus functionality you're looking for. Here is a good resource to get you started with the Tableview control. You can also style the Tableview with CSS to look less like a table and more like a list if thats what your intention is.
The second option is to set a custom cell factory on your ListView that builds custom cells using HBoxes, VBoxes, Labels, etc. to achieve your desired look. You would also want to use the cell factory to populate each ListView cell with an object that contains both the abbreviated text and long version text. A couple good resources, 1, 2
Although I think both option will work fine, I would suggest option 1 since in option 2 you are sort of building a table type structure anyway. I hope this is helpful!

Sencha GXT Grid filters are slow. Can I make them fast?

I'm using GXT Grid with a filter (StoreFilterField to be exact).
The problem is that when filter changes (user types something or clears it) it takes a long time for Grid to refresh.
I have a relatively small grid of 1000 rows with 7 columns. Scrolling works just fine, so I believe browser is able to handle it fast.
Looks like the problem is that when one types filter text method Grid.refresh() is called, which renders all the rows again and again inserting them as one huge HTML String.
Is there a way to make it more efficient? For instance, I would think that hiding elements in existing html that contains unfiltered set of rows would be faster.
Another way is to somehow cache or delay creation of components in the Grid, but I can't find any row caching capabilities in the GXT Grid API. Maybe I overlooked it.
Your help would be much appreciated.
The caching capability is not found in the Grid API itself but in the GridView. Grids have a view attribute that you can set.
What version of GXT are you using? In GXT 2.x, there is view variant called BufferView.
From documentation:
Renders the rows as they scroll into view. This GridView is fast for displaying many rows at once, but it does not support all features the normal {link #GridView} supports, such has expanding rows.
If you are using GXT 3.x, you may have to use LiveGridView instead because they have removed BufferView.
From this, you can specify the cache size, scroll delay, etc.
I hope this helps!
Paul

Categories