i am new bee to uiautomator and when i am trying to clear the text field text with clearTextField() its not at all clearing. Can some one guide me how can i do this.
tried in this way also
while(!"".equals(obj.getText())
obj.clearTextField();
Thanks in advance.
For security reasons, we can't get the text from a password edittext. Unfortunally clearTextField() does not work on API 18 so:
obj.getText() = ""
obj.getText().lenght() = 0
My solution, not very beautifull i know, is:
private static void clearText(UiDevice uiDevice, UiObject textBox) throws UiObjectNotFoundException {
int estimatedLength = 30;
textBox.clickBottomRight();
for (int i = 0; i < estimatedLength; i++) {
uiDevice.pressDelete();
}
}
You can try following code :
String text = obj.getText();
obj.clickBottomRight();
for (int i=0;i<text.length();i++) {
UiDevice.getInstance().pressDelete();
}
obj.setText("some-text");
Related
In my winform app ,
I want to use chart from toolbox (instead of making on using RDLC report).
But in Y axis I want to use expression like =Count((Fields!Number.Value)) but the chart won't allow me to as it simply takes names of he column.
I have tried searching in web but didn't find convincing result. So please share any link or share your knowledge so that I can learn
I also looked at coding options like chart2.Series[0].Points.AddXY(i, 0); but I have no idea how to enter expression in this.
Based on my search, It is hard for us to find a method to use expression directly.
However, I suggest that you can define a method to replace the expression, then you can add the correspond point when you want to use the expression.
Here is a code example you can refer to.
private void Form1_Load(object sender, EventArgs e)
{
chart1.Series.Clear();
var series1 = new System.Windows.Forms.DataVisualization.Charting.Series
{
Name = "Series1",
Color = System.Drawing.Color.Green,
IsVisibleInLegend = false,
IsXValueIndexed = true,
ChartType = SeriesChartType.Line
};
this.chart1.Series.Add(series1);
for (int i = 0; i < 1000; i++)
{
series1.Points.AddXY(i, Result(i));
}
chart1.Invalidate();
}
private int Result(int i)
{
var result = 20 * i + i * i;
return result;
}
Result:
I was trying to create a treeview browser for my application but got stuck somewhere.
The treeview isn't getting displayed.
Code:
System::IO::DirectoryInfo^ info = gcnew System::IO::DirectoryInfo(path);
System::IO::Directory^ dir;
if (dir->Exists(path))
{
try
{
array<System::IO::DirectoryInfo^>^ dirs = info->GetDirectories();
if (dirs->Length > 0)
{
for (int i = 0; i < dirs->Length; i++)
{
TreeNode^ node = treeView1->Nodes[0]->Nodes->Add(dirs[i]->Name);
node->ImageIndex = 1;
for (int j = 0; j < dirs[i]->GetFiles()->Length; j++)
{
if (dirs[i]->GetFiles()[j]->Exists)
{
TreeNode^ nodes = treeView1->Nodes[0]->Nodes[node->Index]->Nodes->Add(dirs[i]->GetFiles()[j]->Name);
nodes->ImageIndex = 2;
}
}
}
}
}
catch (Exception^ e)
{
MessageBox::Show(e->Message);
}
}
Did you use splitcontainer and fill in the first section with your data first?
How did you initialize the new treeview class?
Example:
[ComVisibleAttribute(true)]
[ClassInterfaceAttribute(ClassInterfaceType::AutoDispatch)]
[DockingAttribute(DockingBehavior::Ask)]
public ref class TreeView : public Control
Then you can implement treeview and imageview.
For example, ShGetFolderLocation is one way to pull file locations, for windows OS.
Remember you have to populate the view and tell the system to display it for you to see it.
Or just go to: this earlier solution for the same issue
Follow up with the code for nodemouse click or whatever input response you are looking for such as expand or close, go to link and so on.
This method is not working
/**
* Outputs all details of all customers to the terminal window.
*/
public void getAllBorrowers()
{
int index = 0;
while(index < borrowers.size())
{
borrowers.get(index);
index++;
}
System.out.println("Number of borrowers: " + getNumberOfBorrowers());
}
I am not very sure what are you trying to do here.
But from the function it looks like you are getting borrower from
borrowers.get(index);
But not getting the value and printing it.
Can you please let know what exactly you are expecting here?
I am using horizontal pager
https://github.com/ysamlan/horizontalpager/blob/master/src/com/github/ysamlan/horizontalpager/HorizontalPager.java
to make dynamic views,and making dynamic images in it....
And using fedor imageloader to pupulate imageviews from urls...
https://github.com/thest1/LazyList/blob/master/src/com/fedorvlasov/lazylist/ImageLoader.java
but i am getting that annoying stid image....
here is my code...
Any help or suggestion will be highly appropriated
Thanx in advance
public class testing extends Activity {
private HorizontalPager mPager;
ImageView[] image;
String url = "http://icons-search.com/img/icons-land/IconsLandVistaStyleEmoticonsDemo.zip/IconsLandVistaStyleEmoticonsDemo-PNG-256x256-Cool.png-256x256.png";
#Override
public void onCreate(final Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.testing);
ImageLoader imageLoader = new ImageLoader(this);
mPager = (HorizontalPager) findViewById(R.id.horizontal_pager);
image = new ImageView[2];
for (int i = 0; i < 2; i++) {
image[i] = new ImageView(getApplicationContext());
image[i].setImageResource(R.drawable.logo_background);
RelativeLayout.LayoutParams layoutParams90 = new RelativeLayout.LayoutParams(
225, 250);
layoutParams90.leftMargin = 25;
image[i].setLayoutParams(layoutParams90);
mPager.addView(image[i]);
}
for (int i = 0; i < 2; i++) {
imageLoader.DisplayImage(url, image[i]);
}
}
}
When you create ImageView try to pass your Activity instead of Application context. So replace this
image[i] = new ImageView(getApplicationContext());
with this
image[i] = new ImageView(this);
Please check whether you added external storage and internet permission in your android manifest file?
You need to localize the problem first. Probably there's something wrong with the url you use - try another one. Probably something related to Pager - try without pages, just put all images into LinearLayout. What else may be a problem - just find some clue. Does it work if you just put a single ImageView to the screen?
Knowing the hwnd of the window, how do I read the contents of this? Before anyone ask me, I'm trying to get the text that was used in the Communicator window.
Below is the code I found on the Internet.
The code is not mine.
using System;
using System.Collections.Generic;
using System.Text;
using System.Runtime.InteropServices;
namespace EventFun
{
class EventHookUp
{
CommunicatorAPI.Messenger mCommunicator = null;
static void Main(string[] args)
{
EventHookUp hu = new EventHookUp();
hu.InitializeEventHocks();
Console.ReadKey();
}
public void InitializeEventHocks()
{
mCommunicator = new CommunicatorAPI.Messenger();
mCommunicator.OnIMWindowCreated += new CommunicatorAPI.DMessengerEvents_OnIMWindowCreatedEventHandler(mCommunicator_OnIMWindowCreated);
mCommunicator.OnIMWindowDestroyed += new CommunicatorAPI.DMessengerEvents_OnIMWindowDestroyedEventHandler(mCommunicator_OnIMWindowDestroyed);
}
void mCommunicator_OnIMWindowCreated(object pIMWindow)
{
CommunicatorAPI.IMessengerConversationWndAdvanced stpIMWindow = pIMWindow as CommunicatorAPI.IMessengerConversationWndAdvanced;
//stpIMWindow.History;
long Hwnd = (long)stpIMWindow.HWND;
Console.WriteLine("New IM Window Created : {0}", Hwnd);
CommunicatorAPI.IMessengerContacts contactList = (CommunicatorAPI.IMessengerContacts)stpIMWindow.Contacts;
StringBuilder sb = new StringBuilder();
foreach (CommunicatorAPI.IMessengerContact imc in contactList)
{
sb.Append(imc.FriendlyName);
sb.Append(Environment.NewLine);
}
Console.WriteLine(sb.ToString());
}
void mCommunicator_OnIMWindowDestroyed(object pIMWindow)
{
Console.WriteLine("IM Window Destroyed.");
}
}
}
It sounds like you are trying to get the conversation text history from the conversation window? If so, George Durzi has an excellent blog post on this.
As this blog post is not available, I used below method to retrieve the conversation history:
object obj = msgrAdv.StartConversation(
CONVERSATION_TYPE.CONVERSATION_TYPE_IM, // Type of conversation
sipUris, // object array of signin names for having multiple conversations or just a string
null,
"Test",
"1",
null);
imWindowHandle = long.Parse(obj.ToString());
if (imWindow == null) //If there is already an open window...
{
imWindow = (IMessengerConversationWndAdvanced)msgrAdv.InstantMessage(sipUris);
}
//else there was no open window, we have opened the window using "msgrAdv.StartConversation" so there is a imWindow associated which is implemented in communicator_OnIMWindowCreated.
//and then...
string history = imWindow.History;