How to click on Button hiding inside my text box in the form of image at the corner for appium - appium-android

How to click on Button hiding inside my text box in the form of image at the corner for Appium mobile testing
I need to click on the image. If I click on that image, it will display
one popup and i am unable to find locator separately for the image using
UIAUTOMATOR VIEWER because image is inside my textbox so please help me
to overcome from this i am not able to proceed.
I am using UIautomator viewer tool avalible to find the locator more unique?

You can use TouchAction and click by coordinates:
WebElement accountTextBox = driver.findElement(By.id("account_edit_text"));
Point point = accountTextBox.getLocation();
int shiftX = accountTextBox.getSize().width - 5; // you can adjust it
int shiftY = accountTextBox.getSize().height/2;
new TouchAction(driver)
.press(point.x + shiftX, point.y + shiftY)
.waitAction(ofSeconds(1))
.release()
.perform();
Also you can use Appium-desktop and try automationName capability set to UIAutomator2 and check what XML its gonna build: it might parse button as separate element.

Related

Add text next to UI Form action icon in toolbar?

Is there a way to add text next to the action icon in the toolbar of an eclipse RCP UI Form? If you do not assign the Action an ImageDescriptor, the action will be displayed containing only text. If you do give it an ImageDescriptor, it displays only the image. I want to display both side by side, within one button - is there a way to do this?
This will have only the text "Description" in the button on the toolbar:
myAction = new Action("Description", SWT.PUSH) {
#Override
public void run() {}
};
myForm.getToolBarManager().add(myAction);
But adding an image will cause the the text to be replaced:
myAction.setImageDescriptor(newImage);
I was eventually able to find an answer to my issue, hopefully it's helpful to anyone else who runs into this problem. I found this in the Eclipse Rich Client Platform (2nd Ed.) book.
The Action must be converted to an ActionContributionItem with its mode set to MODE_FORCE_TEXT. This will display both the text and the image in the toolbar.
ActionContributionItem aCI = new ActionContributionItem(myAction);
aCI.setMode(ActionContributionItem.MODE_FORCE_TEXT);
myForm.getToolBarManager().add(aCI);

resize jPanel on VLCJ fullscreen for controlsPanel

I am using netbeans to create a media player using vlcj-3.8.0.jar.Here is the source code for netbeans users,vlcj gui netbeans based just unzip and open project in netbeans(contains playlist, volume, plays in canvas)I know placing the whole code violates the SSCCE standards but it might be informative for others. Another reason is that if you are a netbeans user then running the code and finding the problem is very easy for you, u wont need to search the entire code. So my problem, all works fine but i am having problem when i toggle the fullscreen. The controlsPanel as you can see in the picture below wont resize and i dont how how to do it. I tried to put the panel in border layout but it messes everything inside it(i have jslider and jlabels inside it).
http://postimg.org/image/kcxuwgjgx/
Here is a code to toggle on and off for fullscreen, where
jPanel2: is in border layout that has canvas inside it,
controlsPanel: panel in absolute layout that has jslider and jlabels has properties i set through netbeans as horizonal size and vertical size as default, horizontal resizable as ticked
private void toggle_fullscreenMouseClicked(java.awt.event.MouseEvent evt) {
if(fullscreen_check==1){
controlPanel.setVisible(true);
titlePanel.setVisible(false);
mediaPlayer.setFullScreen(true);
//at fullscreen the controlPanel should be resized horizontally to the end of the screen
controlPanel.setPreferredSize((new Dimension(1200,100)));
controlPanel.setSize((new Dimension(1200,100)));
controlPanel.revalidate();
//here is the problem:controlPanel stays the same...why??
fullscreen_check=0;
}
else{
mediaPlayer.setFullScreen(false);
Dimension ss = new Dimension (10,10);
jPanel2.setPreferredSize(ss);
jPanel2.setSize(ss);
jPanel2.revalidate();
fullscreen_check=1;
}
} `
I tried to use the code:
controlPanel.setPrefferedSize((new Dimension(1200,900);
controlPanel.revalidate();
//OR:
controlPanel.setSize((new Dimension(1200,900);
controlPanel.revalidate();
but it wont work...any help or idea will be greatly appreciated!! If any of you guys tried my code and make the controlsPanel to be resized to full screen, i will be very grateful!!

Add a popup Pane to crossrider add-on icon and bliking icons to the add-on icon

I wanted to migrate my existing add-on for firefox and chrome to crossrider in order to have it also with safari and IE, but i've a few doubts that mayble Schlomo (or any Crossrider developercan) can help me to solve them.
Questions :
Can i add a popup pane when someone clicks on the add-on button showing some kind of options inside it?
Can i add a blinking icon to the actual icon showing some kind of event happened like incoming chat or so?
Is there a way to add the red text box like in chrome showing at the bottom right of the icon some kind of text?
Thanks a lot!
When you pose the question like that, I can only hope the following answers will serve to allay your doubts and enlighten :)
First off, I would recommend familiarizing yourself with How to add a browser button to your Crossrider extension in general and the button popup feature specifically.
In answer to your specific questions:
You can use the button popup feature and build the required options in there. Take a look at the Button Popup Menu demo extension to get you started.
Whilst you can't make the button blink, you can alternate the button icon to make it look like blinking (see example).
In short, yes. Simply use the appAPI.browserAction.setBadgeText and appAPI.browserAction.setBadgeBackgroundColor methods (see example).
The following example bring together the key elements in the background.js code required to achieve the solutions mentioned. Look at the popup.html file in the Button Popup Menu for an example of how to build the options page.
appAPI.ready(function() {
var sid, // Blink interval id
alt=0, // Blink alternation state
icon = { // Blink icons
0: 'icons/icon0.png',
1: 'icons/icon1.png'
};
// Set the initial icon for the button
appAPI.browserAction.setResourceIcon(icon[0]);
// Sets the popup for the button
appAPI.browserAction.setPopup({
resourcePath:'html/popup.html',
height: 300,
width: 300
});
if (true) { // blink condition, set to true for this example
// Blink icon
sid = appAPI.setInterval(function() {
alt = 1 - alt;
appAPI.browserAction.setResourceIcon(icon[alt]);
}, 1 * 1000);
} else {
appAPI.clearInterval(sid);
}
if (true) { // show button text condition, set to true for this example
// Add red text box to icon
appAPI.browserAction.setBadgeText('ext', [255,0,0,255]);
}
});
[Disclosure: I am a crossrider employee]

How can I create a GWT button with both image and text?

I'm trying to create a GWT button that includes both an image and text like this:
I can create and set the button image like this:
PushButton button = new PushButton();
button.getUpFace().setImage(new Image(icon));
but if I do this the image disappears:
button.setText("ABC");
How can I keep both? I would prefer not to use the setHtml method because that would create a new HTTP request
EDIT: The problem with calling setHTML() is that it causes the browser to send another HTTP request to the server. This means that when I change the icon the button is blank for a second or two while the browser waits for a response from the server - obviously this not ideal. I'm looking for a way to use the image that is in memory in the form of a ImageResource object. Thanks!
There are lots of ways to achieve this.
Please have a look at below post asked in the same context:
HTML/CSS - Adding an Icon to a button
Adding icons to an button in gwt
GWT Custom Button with Icon above Text
Sample code:
Button button = new Button();
// get image form CSS resource
String url = new Image(Resources.INSTANCE.cut()).getUrl();
// get image from url
String url = "https://cdn3.iconfinder.com/data/icons/tango-icon-library/48/edit-cut-64.png";
// get image from the project war/images folder
String url = GWT.getHostPageBaseURL() + "images/cut.png";
String html = "<div><center><img src = '" + url
+ "'></img></center><label>Cut</label></br></div>";
button.setHTML(html);
Note: you can move it to CSS as well and append in HTML.
___________-
EDIT
You can achieve it using PushButton as well using setInnerHTML()method that will benefit from ImageResource as well.
final PushButton pushButton = new PushButton(new Image(Resources.INSTANCE.old_cut_icon()));
pushButton.getElement().setInnerHTML("<div><center>"+pushButton.getElement().getInnerHTML()+"</center><label><center>Cut</center></label></div>");
now simply call setImage() whenever needed to change the icon only.
pushButton.getUpFace().setImage(new Image(Resources.INSTANCE.new_cut_icon()));
Screenshot
Set a text on your button. Also set a CSS style:
.myButton {
background-image:url('/images/icon/cut.png');
background-position:center top;
padding: 28px 2px 2px;
}
Adjust padding depending on the size of your image.
An alternative approach is to create a widget that combines a button with a label, and either (1) put them in a LayoutPanel, specifying the position that you want, or (2) use CSS to move the label on top of the button (better).

How to find image on whole screen?

Is it possible to click on an image, that is not located in a specific container element?
When I do have a container, I use something like this:
MyRepo.AnyForm.AnyElement.Click(new Location(Imaging.Load(anyPicture.bmp)));
and that works very well.
But now, I want to click on a menu item inside some context menu that Ranorex is not able to identify. So I want to let Ranorex easily search the whole screen for the target image.
Something like this:
AnyElementThatRepresentsTheWholeScreen.Click(new Location(Imaging.Load(anyPicture.bmp)))
Thanks and regards,
fachexot
I've found it. Here the solution if someone has the same problem:
Host.Local.Click(new Location(Imaging.Load(anyPicture.bmp)));
I have image in GridItem. I am able to find the GridItem and Image.I am not able to Click it from my UI Automation Sample.I am doing it in c++
IUIAutomationElement* p1
.......
.......
POINT clickable;
BOOL gotClickable;
hr = p1->GetClickablePoint(&clickable,&gotClickable);
mouse_event(MOUSEEVENTF_LEFTDOWN | MOUSEEVENTF_LEFTUP,clickable.x,clickable.y,0,0);