Need help on verifyElementNotInViewport : Katalon Studio - katalon-studio

I want to verify if the element is not visible in viewport then scroll to that element, do the click and if already visible in viewport then directly click on the element
For this i am using
if (WebUI.verifyElementNotInViewport(TestObject obj, int timeout) == true) {
WebUI.scrollToElement(TestObject obj, 10)
WebUI.click(TestObject obj)
} else {
WebUI.click(TestObject obj)
}
Here else should be executed if the element is visible and in viewport, but I am getting error "is present but is visible in viewport"
I tried the WebUI.verifyElementInViewport too, but with if the element is not in viewport then I am getting error "is present but is not visible in viewport"

You need to set a Failure Handling after the timeout parameter.
WebUI.verifyElementNotInViewport(TestObject obj, int timeout, FailureHandling flowControl)
Katalon webui-verify-element-visible-in-viewport
In your case "FailureHandling.OPTIONAL" if you don't want your test to fail.
Katalon default-failure-handlingbehavior

Related

Wicket 6 - Feedback message not showing until request after the request in which it happened

I have an AjaxButton. The event fires, and I'm testing a scenario where I need to add a feedback and return without committing the change. I add the feedback at the page level (our feedback only shows page level messages...others are showing on component level feedback panels). I add the WebMarkupContainer that contains the feedback panel to the target. This exact thing works on every other button on the page.
But for this button, which happens to be the only one where defaultformprocessing is not false, the feedback doesn't show. To the user's view, nothing happens except our processing veil appears and then disappears. If I hit submit again, THEN the message and feedback are shown. I stuck a timestamp on it to see if it was showing the one from the 2nd request or the 1st. It's from the 1st.
What's more, a breakpoint in the feedback's filter shows that the filter was never called in the 1st request, but is called BEFORE the event processing on the 2nd request. It accepts the message as intended.
I set defaultformprocessing to FALSE on this button as a test, and in fact, messages suddenly work. But of course, that also means the form doesn't get processed. Can someone help me square this circle?
AjaxButton:
add(new AjaxButton("btnCreateRequest", getForm()) {
#Override
public void onSubmit(AjaxRequestTarget target, Form<?> form) {
//stuff happens
target.add(getFeedbackPanelForAjax());
String date = new Date().toGMTString();
System.out.println("ADDING MESSAGE - " + date);
getPage().error("This is a message! " + date);
return;
}
#Override
public void onError(AjaxRequestTarget target, Form<?> form) {
getPage().error("There was an error processing your request");
target.add(getFeedbackPanelForAjax());
target.add(form);
}
}.setVisible(enabled));
UPDATE:
getFeedbackPanelForAjax returns the web markup container that the feedback resides in. I've also tried adding the feedback directly to the target.
public Component getFeedbackPanelForAjax() {
return (Component) getForm().get("feedbackWmc");
}
Where the feedback is added:
feedback = new FRFeedbackPanel("feedback") {
#Override
public boolean isVisible() {
if(anyMessage()){
return true;
} else {
return false;
}
}
};
// feedback container
WebMarkupContainer feedbackWmc = new WebMarkupContainer("feedbackWmc");
getForm().add(feedbackWmc.setOutputMarkupId(true).setOutputMarkupPlaceholderTag(true));
feedbackWmc.add(feedback.setOutputMarkupId(true).setOutputMarkupPlaceholderTag(true));
I can say that through debugging, I put a breakpoint in anyMessage() and it returns false in this case at the same time that getPage().getFeedbackMessages() returns the message correctly. I commented out this override of isVisible() and indeed, the message shows. The problem is, that it means the artifacts of the feedback panel show when there are no messages as well, which is not what we want.
This anyMessage() solution works perfectly when I'm in an event that is defaultformprocessing=false. I suppose I could do an anyMessage() || getPage().getFeedbackMessages(), but my understanding was that anyMessage was supposed to find if there was ANY message in the hierarchy for this panel. Is that not so?
I assume you cannot replicate the problem in a small quickstart?
One idea: I've seen similar problems when the FeedbackPanel collects its messages too early, i.e. before you add the error to the page.
FeedbackMessagesModel keeps the messages to render until the end of the request - maybe some of your code triggers this by accessing the messages model.

Gui.Window ContextClick

Is there a way to add an Event.ContextClick to a Gui.Window in a Unity Editor script?
The following is my context menu method that I've tried calling from both OnGUI() and my window's WindowFunction (call sites denoted below as "site: no luck"). I have not been able to get the "Success" message to show up unless I'm right clicking directly in the main editor window. If I right click in any of the Gui.Windows I have created, the ContextClick event doesn't show up.
void OnStateContextMenu(){
Event evt = Event.current;
// Ignore anything but contextclicks
if(evt.type != EventType.ContextClick)return;
Debug.Log("Success");
// Add generic menu at context point
GenericMenu menu = new GenericMenu();
menu.AddItem (new GUIContent ("AddState"),false,AddState,evt.mousePosition);
menu.ShowAsContext ();
evt.Use();
}
And the call site(s):
void doWindow(int id){
// OnStateContextMenu(); //site1: no luck
GUI.DragWindow();
}
void OnGUI(){
OnStateContextMenu(); //site2: no luck here either
BeginWindows();
wndRect = GUI.Window(0,wndRect,doWindow,"StateWnd");
EndWindows();
}
Update
For reference, green area responds to right-click, red area does not. But I want it to. The right-click menu I've created has specific actions I only want visible if the mouse cursor right clicks inside one of my windows, the 'Hello' in the image. Note: Ignore the button, right click doesn't work anywhere inside that window.
This might not directly answer your question but should be able to help
You are trying to achieve a rightclick function inside your red box( as shown in picute )
I had a sort alike question a while back but it was not for a rightclick but for a mouseover
so i figured this might be able to help you
string mouseover; // first of i created a new string
if (GUI.Button (new Rect (100,100,200,200),new GUIContent("Load game", "MouseOverOnButton0") ,menutexture ))
{
//added a mousoveronbutton command to my GUIcontent
executestuff();
}
buttoncheck();
}
void buttoncheck()
{
mouseover = GUI.tooltip;
if(mouseover == "MouseOverOnButton0")
{
GUI.Box(new Rect(380,45,235,25),"Not a implemented function as of yet ");
}
}
this code made a new gui box the moment the mouse hitted the box.
If you created the hello in a seperate box you could use this
if(mouseover == hello)
{
if(rightclick == true)
{
execute the stuff you want
}
}
or something like that. Hope this helps a bit atleast
UPDATE
To obtain the rightclick event you will have to use the
if(Event.current.button == 1 && Event.current.isMouse)
You have to place this in the OnGUI to work properly
this way you first trigger the in box part, then check for a right click and execute the stuff you want.

Custom cell in gwt CellTree

I've got a CellTree working with simple text cells.
Now I want, for every tree node, a different kind of cell depending on if it is a leaf or not.
This cells would be:
(1) if the node is a leaf (doesn't have children): a TextCell
(2) if the node is a root (it has >= children):.
- It must display the same string as the leafs
- + 1 clickable image (this is an icon that is used to rename the node's name).
- + 1 clickable image (this is an icon that is used to remove the node).
I've tried with:
(1) Custom cell, extending AbstractCell. The point here is that I can't get the clickable images to respond to de mouse click. So no action can be performed (edit name or remove node).
(2) CompositeCell. The point here is that altought I get the clickable images to respond on mouseclick, I can't get an implementation that chooses correctly which kind of cell must be displayed (based on if it has children or not, show TetxCell or custom cell with icons).
Could someone explain how I could achieve this? My code so far is:
public NodeInfo getNodeInfo(T value) {
if (value == null) {
return new DefaultNodeInfo<CellTreeNode>(treeData.getDataProvider(), new IconCell(!isLeaf(value)),
selectionModel, null);
}
else if (value instanceof CellTreeNode) {
CellTreeNode node = (CellTreeNode) value;
//data provider for this cell
ListDataProvider<CellTreeNode> nodeDataProvider = new ListDataProvider<CellTreeNode>(node.getChildren());
IconCell nodeCell = new IconCell(this, node, !isLeaf(node));
// add a reference to the visual representation of the element
node.setCell(nodeCell);
return new DefaultNodeInfo<CellTreeNode>(nodeDataProvider, nodeCell,
selectionModel, null);
}
// Unhandled type.
String type = value.getClass().getName();
throw new IllegalArgumentException(
"[CellLargeTreeListBox] Unsupported object type: " + type);
}
// Check if the specified value represents a leaf node. Leaf nodes cannot be
// opened.
public boolean isLeaf(Object value)
{
if (value == null) return false;
CellTreeNode node = (CellTreeNode) value;
return value instanceof CellTreeNode && !node.isRoot();
}
The cell won't depend on the value it'll display, but on the value of the parent node.
So, you'll need a generic cell that supports both renderings/behaviors and switches between them based on the value it's asked to display: for a value that you can tell is a leaf, then only render text, otherwise also render the images/buttons (note you can also render the same HTML –to make it possible/easier to use a CompositeCell– but switch visibility of the images/buttons using CSS (class=xxx rendered on a container element).

GWT SimplePager LastButton issue

I am facing problem with lastButton of SimplePager.
I have 3 pages in celltable, Page size=11 (1 empty record + 10 records(with value)), Total record=26.
I used CustomerPager by extending SimplePager.
In 1st attempt 1+10 records display in celltable : Next & Last page button is enabled (First & Prev button disabled) which is correct.
But LastPage button not working... :( Dont know whats the issue... (event not fires)
Strange behavior:
#1 Last page button is working only when I visit to last page(3 page in my case).
#2 Assume I am on 1st page n I moved to 2nd page(Total 3 pages in celltable). that time all buttons are enabled which is correct.
In this case Last button is working but behave like Next Button
My GWT application integrated into one of our product so cant debug it from client side.
May be index value is improper in setPage(int index) method from AbstractPager
Code flow is as follows for Last button
//From SimplePager
lastPage.addClickHandler(new ClickHandler() {
public void onClick(ClickEvent event) {
lastPage();
}
});
#Override
public void lastPage() {
super.lastPage();
}
// From AbstractPager
/**
* Go to the last page.
*/
protected void lastPage() {
setPage(getPageCount() - 1);
}
protected void setPage(int index) {
if (display != null && (!isRangeLimited || !display.isRowCountExact() || hasPage(index))) {
// We don't use the local version of setPageStart because it would
// constrain the index, but the user probably wants to use absolute page
// indexes.
int pageSize = getPageSize();
display.setVisibleRange(pageSize * index, pageSize);
}
}
or may be some conditions false from above code(from setPage())
actual record = 26 and 3 Empty record (1st Empty record/page)
May b problem with dataSize :|
How I can check number of pages based on the data size?
?
How can I solve this problem?
edit: I found out that the default constructor of the pager doesn't give you a "last" button, but a "fast forward 1000 lines" button instead (horrible, right?) .
call the following constructor like so, and see your problem solved:
SimplePager.Resources resources = GWT.create(SimplePager.Resources.class);
SimplePager simplePager = new SimplePager(TextLocation.CENTER, resources , false, 1000, true);
the first "false" flag turns off the "fastforward button" and the last "true" flag turns on the "last" button.
also the last button will work only if the pager knows the total amount of records you have.
you can call the table's setRowCount function to update the total like so:
int totalRecordsSize = 26; //the total amount of records you have
boolean isTotalExact = true; //is it an estimate or an exact match
table.setRowCount(totalRecordsSize , isTotalExact); //sets the table's total and updates the pager (assuming you called pager.setDisplay(table) before)
if you are working with an attached DataProvider, than all it's updateRowCount method instead (same usage).
Without seeing more of your code, this is a hard question to answer as there could be multiple places where things are going wrong.
I would make sure you call setDisplay(...) on your SimplePager so it has the data it needs calculate its ranges.
If you can't run in devmode, I recommend setting up some GWT logging in the browser (write the logs to a popup panel or something, see this discussion for an example).
I think the problem is related with condition in the setPage(). Try putting SOP before if condition or debug the code
Only added cellTable.setRowCount(int size, boolean isExact) in OnRange change method AsyncDataProvider. My problem is solved :)
protected void onRangeChanged(HasData<RecordVO> display) {
//----- Some code --------
cellTable.setRowCount(searchRecordCount, false);
//----- Some code --------
}

Set focus to embedded MSHTML

In my application I have an embedded MSHTML control. The problem is that I cannot set focus to this control. I can click, select, push buttons etc, but it won't accept keyboard input and mouse wheel notifications as a result. Even left-clicks on the control do not set the focus. (The question is related to this issue.)
Ultimately, I've tried 4 approaches. (Error handling is omitted here for brevity.) The first is sending WM_SETFOCUS to the control.
HWND iehwnd = ::FindWindowEx (m_oleObjectHWND, NULL,
L"Shell DocObject View", NULL);
if(iehwnd != NULL)
{
iehwnd = ::FindWindowEx (iehwnd, NULL, L"Internet Explorer_Server", NULL);
if(iehwnd != NULL)
{
::PostMessage(iehwnd, WM_SETFOCUS, (WPARAM)GetHWND(), NULL);
}
}
Using Winspector, I made sure that the messages came through to the control's window, but it seems to ignore them.
The second is calling the focus() method of IHtmlWindow2.
IHTMLDocument2* pHTMLDoc2 = NULL;
m_webBrowser->get_Document((IDispatch**)&pHTMLDoc2);
IHTMLWindow2* pWindow = 0;
pHTMLDoc2->get_parentWindow(&pWindow);
pWindow->focus();
This time, I get E_FAIL from focus().
MSDN says that the call may fail when the document hasn't loaded, but pHTMLDoc2->get_readyState() returns "complete". So this isn't the case.
The third is doing the UIACTIVATE verb.
hret = m_oleObject->DoVerb(OLEIVERB_UIACTIVATE, NULL,
clientSite, 0, (HWND)GetHWND(), &posRect);
This seems to achieve nothing.
The fourth is calling focus() of IHtmlDocument4.
IDispatch* pdisp = NULL;
m_webBrowser->get_Document((IDispatch**)&pdisp);
IHTMLDocument4* pHTMLDoc4 = NULL;
pdisp->QueryInterface(IID_IHTMLDocument4, (void**)(&pHTMLDoc4));
pHTMLDoc4->focus();
Does nothing.
I've spent a full day on this already and know google's links by heart now :) Hoping for a hint from experts.
Finally found it.
This function in my code (or rather the IEHtmlWin component for the wxWidgets library) returned S_FALSE. I changed the return code to S_OK - and voila...
HRESULT FS_IOleInPlaceSiteWindowless::RequestUIActivate()
{
return S_OK;
}