Taking a screenshot using Selenium, and removing an element from the screenshot - java

I am wondering what the best way to approach this problem will be. The approach I had thought of doesn't seem very optimal, and I was hoping someone might have encountered this problem before, or might have a better solution.
My approach seems to be to get the coordinates of my screenshot and the element I am trying to remove, along with the length and width of both my screenshot and the element I am trying to remove. Then I would have to make sure that the element exists at least partially within my screenshot, and set two points at the opposite points of the region that exist within the screenshot, and finally paint over that area.
I am implementing automated layout testing, which will require me to test whether web elements remain the same between tests, while ignoring web elements that may exist inside of these web elements. One example of this may be the Stack Overflow navigation bar. I might expect the logo, help bar and search bar to appear in the same place every time I visit Stack Overflow, but I do not care about the number of inbox messages that I have, and nor do I care about testing the reputation number and the profile image, nor whether I have new achievements.
What would be your approach to this problem?

Everything what you've asked [One example of this may be the Stack Overflow navigation bar. I might expect the logo, help bar and search bar to appear in the same place every time I visit Stack Overflow, but I do not care about the number of inbox messages that I have, and nor do I care about testing the reputation number and the profile image, nor whether I have new achievements] can be achieved easily via Galen Framework
Galen is an open-source tool for testing layout and responsive design of web applications. It is also a powerfull functional testing framework.
How does it work?
Galen Framework uses Selenium in order to open web browser and select the tested elements on page. It has a special language to describe the layout of web page for different browser sizes. You just need to define your own tags for devices and sizes and then using the galen spec language write checks for each element on page. The best way to test the layout is to check location and dimensions of elements relatively to each other.

Related

JavaFX - Sequential Transition modify at runtime

I have been exploring the Sequential Transition from JavaFX, and it seems a perfect fit for what I need. So, I am working on a JavaFX desktop application that essentially shows some pictures, text, and plays some video and audio files. Now, since some of those items are presented sequentially, I have decided to use the sequential transition. Now, I just run into a problem that I have tried to address but it does not seem to work as expected. Let's imagine that the sequence in which those items are presented is predefined in a Map. When those items are presented to the user, he/she needs to provide an answer, and if that is correct you can think that the item can be categorized as Done. However, in some of the cases I need that the user repeats some of the items for learning purposes. And that has to be done 'on-the-fly' since I have another window in which someone else decides which items must be repeated. As you can see, this requires some modification of the sequential transition at runtime. Is there any suggestions on how to address this challenge?
Thanks,
As the documentation for SequentialTransition states:
It is not possible to change the children of a running SequentialTransition. If the children are changed for a running SequentialTransition, the animation has to be stopped and started again to pick up the new value.

Disable Materialize Framework "Responsiveness"

I am attempting to use the materialize framework. I am very much liking the features it provides but I don't really care too much about making everything "responsive" right now. I would like to make things somewhat "static", meaning when I resize the browser, everything stays the same size (and user can scroll around in a smaller window to find what they want). I plan to later work on the full "responsiveness" to support things like mobile, window resizing, etc. Below shows whats currently happening. I downloaded the whole framework so I'm free to alter the .css that comes along with it, but I'm not really a .css expert so not really sure where to begin.
Full Screen
Resized Screen - obviously cannot stay like this forever
Any help is much appreciated.
First to answer your question directly: I assume you are using the Materialize grid? Meaning you have divs with class names like "col l6"? To have non responsive elements you should not use any materialize column class names. It will then just be regular old HTML and CSS that you define. Materialize only applies its CSS to elements that use its classnames.
Now for a recommendation: This will probably break some of the features of Materialize. Or at the very least, it will look gross and you will have to add padding/margins everywhere manually. Then if you want to go back and enable mobile responsiveness, you will have to manually remove all of that. You will also have to use old fashioned CSS rules to determine you element sizing. Every element will need a height and width rule applied to it. It is a lot harder to add mobile responsive classes later. It will save you a lot of time if you just do it now. It's quite easy in Materialize once you get the hang of it.
One of the main reasons that Materialize and Bootstrap and the like are used, is to make mobile responsive websites easy. It really is an essential skill to learn for web development these days.

Using Java Swing, how could one implement a search box that has options similar to web browsers or iTunes?

Didn't know quite how to title this question, so suggested edits are welcome.
Right now, I have a fairly simple pair of JComboBoxes for searching row & column headers in a heatmap display. It's been augmented with the ability to allow wildcards. Here's what it looks like:
It works well enough, but a new requirement for the next version is to consolidate the pair of search boxes into 1 search box plus a few other enhancements. Basically, what we'd like to do is enter a search term and have the resulting dropdown have 2 sections: 1 for options and another for the matching results. The desired options would be things like this:
Search rows/columns checkboxes
song/artist/genre checkboxes (to use the iTunes analogy) or google/bing (to use the browser analogy)
Search within previous search results: like have a previous search term with an 'x' next to it to clear it. It would act like a filter.
The thing about this is, the desire to consolidate 2 search boxes to 1 is to simplify the interface, but at the same time, we want this additional functionality.
A JComboBox doesn't seem to be able to handle something like this, and my search for alternatives isn't yielding anything. I know this question is somewhat of a broad design question, perhaps not appropriate for stack exchange. I'm still fairly new to Java, so any suggestions are appreciated.
UPDATE: One of the commenters asked for something more specific and pointed out the existence of different types of iTunes searches based on context, which I'd like to disambiguate. Taking a look at how iTunes does it, I decided to try to mock up a graphic of what I was thinking I could do:
So given this specific example, I envision separating the combo box and the search options, perhaps with a JMenu revealed using a button made to look like iTunes' search options feature.
So my evolved questions are (based on the above mock-up):
Can JMenu do this or is there another type of button-initiated menu I should use?
Can menu selections trigger a re-population of the list the JComboBox provides or would that have bad side-effects?
How can I alleviate the confusion of having a drop-down on either side of the search field?

choosing components in Vaadin

My task is to create a grid with different cars on one axis, and different dates on another one. The content of the grid is going to be different tasks that are going to be carried out by different cars on different days. Basically - its a scheduling program. There has to be a drag and drop function between a list of tasks and the grid. I've been trying to get started all day but have not come far. I really need your help me with the following:
What component should I use to create the grid? Labels for different dates with boxes that together form a grid, or should I use a specific grid function?
What component should I use to create the list of tasks? I would like to be able to add tasks to the list that I can then drag out to the grid, but it's not a requirement. Ive tried to use the Listselector because of its persuasive list-appearance, but as the name might reveal its a selector. I really cant find any method to add things to the list, or for that matter to create the drag function?
I would be exteremly thankful if you would lend me a helping hand. And please - feel free to PM me or write a comment here.
Have you seen the Vaadin Demo site? They have many widgets used in various scenarios. Click to see the source code.
Here is one that does almost exactly your case: Drag items between tree and table.
Vaadin is brilliantly designed, with consistency. Once you learn about a few widgets you will see the same patterns being used elsewhere. In particular, study the Item and Container interfaces and classes, as discussed in this chapter Collecting Items in Containers.
Read various chapters the Book of Vaadin web site. Lots of info and examples.

"Quick find" for an SWT Table

I have a table that displays the output from a database, this can often be up to or over 10,000 rows. I'm looking to implement a 'quick find' function that will allow the user to easily scroll to a row with the value for which they search.
The idea is for this to be very similar to Chrome or Firefox's quick find. So:
User hits 'CTRL+F'
A box pops up:
The user can then quickly skim through the table pushing / or /\ to each matching value
My question is, does such a table already exist? I have looked at NatTable and XViewer but they both seem like rather large additions for a relatively minor change.
Another library I've looked at that is close to fitting the billl is Lucene TableSearcher unfortunately this is designed for filtering rather than highlighting. However it may be an avenue worth investigating.
It's not quite the same, but JFace does have support for filtering views. You type in a text box and view contents shrink to what matches the filter. It's basically another way to present search/find functionality to the user.
You can see this in action in Eclipse Preferences (the filter text field about the navigation tree in the dialog). See org.eclipse.ui.dialogs.FilteredTree class. I don't believe there is a FilteredTable or equivalent, but underlying facilities are pretty generic, so it shouldn't take much work to put one together. Take a look at FilteredTree source and go from there.
The solution I chose wasn't as simple as I'd hoped but has a satisfactory performance.
The tables involved are virtual tables that can be very large. So on top of this upon loading the dataset we start a thread to build an index in the form of a list. Because these tables can be very large (but aren't often) we set a 50mb limit to this list and stop indexing it when we hit it. For most cases this is perfectly acceptable but for the larger tables it means that whilst it may be slower, it is considerably more stable than other options.
The 'search' is a simple SWT textbox with ModifyListener that iterates over the list, performing a 'contains' on each entry. Upon a match the row and column are calculated from the index number (0=0,0, 1=0,1 ..).
It would have been nice to have a simple 'drop in' solution for this but all of the tables on offer had too many features.
Use FilteredItemsSelectionDialog dialog box

Categories

Resources