Hi i am new on automating mobile apps, some help would be appreciated.
i want to select some images from gallery through app, however all the images are having same class name and i can select only one image, while trying to select other image it just deselects first image and select that image again.
driver.findElement(By.xpath("//android.widget.TextView[#text='pictures']")).click(); //image selection // select folder
if(Product.equalsIgnoreCase("Photobooks"))
{
// number of images to be selected is equal to
for(int i=0;i<40;i++){
Thread.sleep(5000);
driver.findElement(By.className("android.widget.ImageView")).click();
}
This code goes clicks on one folder containing images and tries to selelct 40 images from the gallery to design book.
The problem is that you keep finding the same element.
What you need to do is to get the list of ALL the images, and then click on every image from that list:
List<WebElement> imageList = driver.findElements(By.className("android.widget.ImageView")).click();
if(Product.equalsIgnoreCase("Photobooks"))
{
// number of images to be selected is equal to
for(int i=0;i<40;i++){
imageList.get(i).click();
Thread.sleep(5000);
}
}
Related
I've used this :
Elements images = doc.select("img[id^=dimg]");
Element image = images.first();
String url = image.absUrl("src");
As div.img-brk is an element represent the images block and I want to fetch the first image there.
div.img-brk img refer to the img decendents of div.img-brk.
adding the url I'm trying to get the image from. Here
I have a form, where I have a imageview and other two text fields. This imageview will be updated with the pic a user chooses(either from gallery or by taking a pic). I will be saving this image in internal storage and other two text fields and saved image path in SQLite DB.
User has option of not choosing any image. In that case I should not save any image, coz I simply be wasting storage. For that how do I distinguish when a user chooses or not to upload any image?
int NEW_PIC=1;
int NO_CHANGE=0;
initialise
img_camera.setTag(AppConfig.NO_CHANGE);
when Changed set
img_camera.setTag(AppConfig.NEW_PIC_ADDED);
if ((int) iv_userImage.getTag() == NEW_PIC_ADDED) {
//New Image Added
}
else{
//Not New
}
I am making an application that allows the user to upload multiple images from the gallery. The user selects the photos and they are displayed in a list view and the user clicks an upload button. It was working fine until i discovered some images were changing orientation on the list view and on upload.
I asked around about the issue and someone told me that i had to allow for cropping before upload. Should i make the user crop every selected image from gallery or how should i go about it?
if (requestCode == SELECT_MULTIPLE_PHOTOS) {
String imagesArray = data.getStringExtra(EXTRA_SELECTED_PHOTOS);//get Intent data
//Convert string array into List by splitting by ',' and substring after '[' and before ']'
List<String> selectedImages =
Arrays.asList(imagesArray.substring(1, imagesArray.length() - 1)
.split(", "));
Log.d(TAG, "Selected images is " + selectedImages.size());
mPhotosPathList = new ArrayList<String>(selectedImages);
Log.d(TAG, "Selected images path is " + mPhotosPathList.size());
}
Get the image orientation. If it is not in the correct orientation, the get the correct orientation, Try this link
I am using square picasso library to download some images from one of our servers and load it in a list view. In my Android application I have a feature to change that downloaded image from app side and upload it to server.
I do know how to load the image from URL because it is well documented. What I need is to change/delete a particular cached item and replace it with my new image from Android application side.
Please help me.
Thanks in Advance....!
Suppose you have a List which stores your images, used by your ListView. You assign an Adapter
to your ListView which fills ListView from the List.
This is how you can replace an old (cached item) by the new one and release space for the old one:
public void replaceListItem (List<Bitmap> list, int position, Bitmap newBitmap) {
Bitmap oldBitmap = list.set(position, newBitmap);
if (oldBitmap != null)
oldBitmap.recycle(); // This will release space for the old bitmap
}
The function does not check if position is within the size, neither it checks if the new bitmap is already there, etc. I just wanted to concentrate on the question you asked.
I'm stuck with the following scenario and appreciate any help/advice..
Requirement
I have number of categories and subcatergories in my application. Say for example, I have a category "Food" and under which I have subcategories: Mexican, Chinese, Italian etc.. I have around 20 categories and each category has around 30 subcategories.
Each subcategory/category has an Icon associated with it
User would be able to select one or more of these sub-categories, so the UI would be a seectable list view.
Questions:
What's the best way to store and retrieve this data (Strings and Icons), serverside or client side ?
Is there a way to load icons dynamically at runtime, when I show the subcategories? (using http?)
Thanks in advance !
Why would you fetch icon-data from a server? 20 * 30 = 600 icons.
You probably will save hard drive space with respect to the installation. But personally I wouldn't go for that solution.
If you're not in need of a client/server - approach then don't use it. What if the server for example breaks down, or you don't have an internet connection?. The application will then be useless :)
You can load images dynamically as:
BitmapFactory.Options options = new BitmapFactory.Options();
options.outWidth= IMAGE_WIDTH;
options.outHeight= IMAGE_HEIGHT;
Bitmap bm = BitmapFactory.decodeFile("icon image file path", options);
imageView.setImageBitmap(bm);
In your case, you can download all the required icons on mobile's sdcard. So in future,if sub categories increases then you can download new icons for that and can dynamically render on UI.