Karate-Robot: How to scroll through a datagrid element? - karate

I have been using the Karate framework Robot component for desktop UI automation. With it, I need to click on a button in each row item of a data grid and using click() doesn't work when the item is not in view/is offscreen. As such I'm trying to figure out how to scroll down to the items I need so I can click the button. I noticed with the driver there is an option to scroll() but I haven't been able to find one with Robot.
Is there a workaround for this or are there plans to add a scroll() function for karate-robot in the future?

Scroll certainly sounds like it may be missing from the existing API. Please do consider investigating and contributing to the code, which will just make it faster to release.
Meanwhile here are the possible workarounds:
see if using the TAB key auto-scrolls to the element
if you get a reference to the button you can call invoke() on it which is supported by a range of windows components
P.S. please do consider contributing code, the code base is actually quite simple. And here is where you can implement the Scroll pattern: link.

Related

Click not working on combo-box down arrow button karate UI testing

I tried clicking on down arrow button for a Combo Box (Select is not available. Its a React JS application and once I click on arrow button only list shows selection items) using below karate command but click not happened in application and no error displayed. [The same xpath worked in selenium click command,and showing unique item on Inspect search]
And waitFor("//div[#id='root']/div/div[3]/main/div/div[3]/div[2]/div")
And click("//div[#id='root']/div/div[3]/main/div/div[3]/div[2]/div")
Note: Then I tried below command
And assert('//div[#id='root']/div/div[3]/main/div/div[3]/div[2]/div').exists
and got error
javascript evaluation failed: assert('//div[#id='root']/div/div[3]/main/div/div[3]/div[2]/div').exists, :1:19 Expected , but found root
assert('//div[#id='root']/div/div[3]/main/div/div[3]/div[2]/div').exists
It would really help us if you follow this process, it is simple and should not take much time for you to give us a small snippet of static HTML (or you can mix react if really needed).
https://github.com/intuit/karate/tree/master/examples/ui-test
EDIT: you also seem to have mis-matched single and double-quotes in your code.
Also note that you should be able to fire a JS event or click by using the script() API. See this example: https://github.com/intuit/karate/tree/master/karate-core#script
So this is an alternate approach to be able to overcome any tricky situation that comes up.

Hover in Selenium does not work

This is not really question, but just sharing my experience.
I am testing a page containing charts. Whenever a hover action by mouse is done, it shows small hint next to it. This work perfectly interacting with the element manually. The problem happens when trying to hover over element from Selenium.
I tested it with the following code, but it did not work
new Actions(getDriver()).moveToElement(graphElement).build().perform();
It only works if the folowing code is executed prior to using Actions
graphElement.click();
Even though the Actions click() method does not work. It really needs to be clicked through WebElement.click() and then use Actions...
Does anyone have similar experience with this behaviour? Why does the element should be clicked on before the Actions can work?
Because it is in contrary with the flow. Why anyone would start with clicking on the element to check that some message is displayed on hover action?
JS workaround (hover) does not help as well.
Thanks for your posts.
I just searched and found very neat solution.
Using the following code solved that problem with focus.
graphElement.sendKeys("");
so the final version
graphElement.sendKeys("");
new Actions(getDriver()).moveToElement(graphElement).build().perform();

Tab Order in Visual Studio hates me

Tab Order in Visual Studio does not work for me for some reason.
I am making a VB.NET plugin for a cad program called Rhinocreos 5.
I have everything set perfect, and I don't know what the cause of it is.
I am using .Show() instead of .ShowDialog(), because I need that thread open and I don't feel like doing any thread management (not paid enough lol)
Does anyone have any pointers for this? Has anyone else ran into a tab problem with Rhino5 and .NET?
EDIT**
Seems I have to use a MODELESS Form for a rhino plugin.... So I wont have any tab keys or arrow keys unless I do a hook. But since I need to make the plugin future proof (in case I am no longer working here), I won't be doing that either. But thanks for the answers, comments, and awesome downvotes.
Very difficult to guess what's going on from the information you have provided, but I'd check the following things in the following order:
The disobedient form is open and has focus.
The form has controls in it.
At least some of the controls are enabled, focusable have their TabStop set to true.
There is no low-level keyboard handling in action (PreviewKeyDown, hooks etc).
Finally I'd call ShowDialog() instead of Show(), passing main form as parameter (to make disobedient form a child of main form) and see if that makes a difference.
It was a modeless form inside of Rhino3D as a plugin.
Rhino3D uses all plugins in the main thread. So tab is not an option.
The workaround was to tag all controls with a tag work (I used "tabMe")
Then I store all the controls in a List myTabbyControls.
Each time I press tab, I would cycle through the list.
But thanks for the down votes. It's the running joke of SO.

Selenium element.click() does not work

Hello: I am using Selenium/Java to grab a PDF from a website. The website does not generate them in advance, but only after I clink on a link. When I do, the web server goes away for a few minutes, and then comes back with the content.
I'm using Firefox, and its built-in PDF viewer. When I click on the download link from the main browser window, it opens another window to receive the PDF content. In a few minutes the child window is filled with the PDF content, and all I need to do is click a download button on the Firefox toolbar, and then press a Save button on the confimration dialog. I have done both of these things, successfully, sometimes.
My problem, sometimes occurs when I execute the code to click on the child window's download button...
WebElement element = driver.findElement(By.id("download"));
element.click();
Sometimes, it just doesn't work. The statement:
driver.findElement(By.id("download"))
...never throws an exception, so it appears to always be successful. Yet, the subsequent element.click() will often not produce the expected results.
I've thrown about 100 darts at this problem, but I can't seem to find one that produces consistent results. I've tried introducing delays, calling findElement several times, trying to use the driver on the child window in ways to confirm its connection to that window (all with positive return values), but nothing seems to help make element.click() on the darn download link successfull.
I have found Selenium to be a rock-solid solution, especially when working through the primary window...it never misses a beat, and I'm really quite impressed about that behavior. This is my first Selenium project, and I hoping someone that has used it a bit more, might have a suggestion for this particular problem.
It's hard to answer this question without additional information about how the child window is populated. If the child window is using javascript to add the button to the page and define its behavior (which is likely), then the element could be actually present on the page when you look for it (i.e. no error will be thrown), but it might not be active yet or prepared to be clicked.
It might be a good idea to look at the element definition in the source for the child page to get a better idea of how the button is coded. If you have access to the web developers who designed/implemented the button even better. If you can wait to perform the click action until the button is in the desired state, this should solve the problem.
Additionally if the page is coded using a dynamic framework like Angular, you might be better off using Protractor for testing, which is based off of Selenium, but which is aware of updates in the view as they are occurring.

Some mouse clicks don't register in Selenium

I've got a rather Javascript-heavy page with lots of contents generated via AJAX or other scripts. On some of these elements Selenium can record mouse clicks, while on others it ignores them. I haven't found any correlation. Perhaps there are some known common scenarios where Selenium cannot intercept mouse clicks?
Unfortunately not all clicks in Selenium are equal. Some are mouseDown and MouseUp or a variation on that. I would play around with that to get your app working.
Unfortunately Selenium IDE has been misrepresented. It is a Record/Tweak/Playback tool not a record/playback tool.
There's no list of actions that are unreliable. In my experience there's no pattern to which elements work, but it's consistent throughout executions of the test. In case you were thinking about it, playing around with locators or UI-Elements is very unlikely to improve your results.
I recently had a situation with a number of dropdown menus, all implemented in the same way, on multiple different pages. On certain pages, dropdown #2 and #3 wouldn't work, yet on other pages they would work, but dropdowns #1 and #2 wouldn't.
As has already been pointed out, the best thing to do is stop thinking about Selenium IDE as a record-playback tool.
On a sidenote, you may be asking this question for a similar reason I was, which was wanting to use Selenium IDE as a frontend for teammates without Selenium programming experience to create tests with, then one thing I did find helpful was extending the Selenium IDE by adding a Command Builder, which allows you to control what appears in the right-click menu when using the IDE.
This means you can press record, go about recording your test as normal while keeping an eye on what has been recorded. Once you see Selenium IDE has failed to record an action, you can just right-click the element and the action you wanted to record will be easily available.
Not a solution to your original question, but it's helped me out. It's very simple to write an extension to the right-click menu, there's some really good examples on this Selenium website.
I'm a 100% selenium noob, but I had the same problem and solved it through the following workaround:
Right-click the to-be-clicked item
Choose a random command that has the entire locator text, e.g. assertText //div[2]/div[5]/table/tbody/tr[1]/td[1]/div IR or something. Look inside "Show all available commands" too.
In the Selenium IDE, change the command to "click" and remove the 2nd argument (the Value field; if any)
Hacky, and should be easily improved with a custom command in the right-click menu, but for now this works fine for me.
Did you try clickAt with location (0,0)? It sometimes helps
If you have assigned an ID to the element you want to click I would suggest you try a simple script, you can perform this through the IDE:
runScriptAndWait
jQuery("#yourButton").trigger('click');
I have used this in the past and it works just fine.