I am trying to select an image from Android image galley grid view. This grid view has ImageView for every image. Every ImageView has id.
So when i am trying to get by //ImageView[#id="someId"][1] or by //GridView[#id="someId"]//ImageView[#id="someId"][1], it does not find it.
How can I select image from gallery using Selenium webdriver in ruby.
EDIT:
<GridView id = "someId">
<LinearView>
<ImageView id = "someImageId"></ImageView>
</LinearView>
<LinearView>
<ImageView id = "someImageId"></ImageView>
</LinearView>
<LinearView>
<ImageView id = "someImageId"></ImageView>
</LinearView>
<LinearView>
<ImageView id = "someImageId"></ImageView>
</LinearView>
</GridView>
EDIT
As Uiautomator cannot select the thumbnails in Gallery, I tried to pick image using relative co ordinates but this is giving an error.
Is any one has done this? I need to select image from android gallery.
If you want the first image (ImageView) :
//*[#id='someId']/LinearView[1]/ImageView
Output :
<ImageView id="someImageId"/>
You can change the index in the LienarView array selection.
element = driver.find_element(:xpath, "//*[#id='someId']/LinearView[1]/ImageView")
p element
# <Selenium::WebDriver::Element:0x3eb6a9d8 id="{ea847fbe-7fc7-453b-97ea-74fbf325ddac}">
edit :
You can also fetch all elements using find_elements() into an array and then, juste select the one you want :
elements = driver.find_elements(:xpath, '//ImageView')
p elements[1]
# <Selenium::WebDriver::Element:0x..f9bdc4412 id="{1f41fbd9-0a73-4fb2-9c98-44bb877e2388}">
You should be able to find it with Appium using:
//android.widget.ImageView[#id="someId"][1]
or
//android.widget.GridView[#id="someId"]//android.widget.ImageView[#id="someId"][1]
Related
So the simple idea is that I have SVG data as a string that I fetch from Internet.
I would like to show that as an icon in my app. Is there any way I can do this?
I have seen countless examples where SVG data is in a file located in the app's directory that is then showed but this is not what I am looking for. I literally have the data in XML format after http request and I only need to transform that to a Image or something else visible on the screen.
I have been trying to find a solution to this for hours now, so I would really appreciate some help :S
Android doesn't support svg with ImageView directly,you could display SVG with some commonly used third-party controls.
Like FFImageLoading.
Add Xamarin.FFImageLoading.Svg nuget package to platform project. Use ImageService with svg data resolver for displaying svg images.
For Android:
<ImageView
android:id="#+id/image_view"
android:layout_width="match_parent"
android:layout_height="match_parent"/>
then use like:
var svgString = #"<svg><rect width=""30"" height=""30"" style=""fill:blue"" /></svg>";
ImageView imageView = FindViewById<ImageView>(Resource.Id.image_view);
ImageService.Instance
.LoadString(svgString)
.LoadingPlaceholder(placeHolderPath)
.WithCustomDataResolver(new SvgDataResolver(64, 0, true))
.WithCustomLoadingPlaceholderDataResolver(new SvgDataResolver(64, 0, true))
.Into(imageView);
BackgroundImage="Picture/abc.jpg"
in content page I have added this but it not display image in android display in UWP Project
Please put your Image in to the Resource folder like following screenshot.
Then use it in xamarin forms.
In your situation, you can put your image to Resource, then set it like following code.
MyImage.Source = Device.RuntimePlatform == Device.Android ? ImageSource.FromFile("hk,jpg") : ImageSource.FromFile("Picture/abc.jpg");
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
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);
}
}
i developing an application, in that i configure html data . But the background image for data is not effected means the image path is not getting.
i placed my image :res/drawable-hdpi folder.
and i am using the following logic:
strBody += "<tr><td background='../res/drawable-hdpi/msgblue_box.png' style='word-break:break-all;width:50%;'>" + dslist.get(i).getBody()+"<br>"+ dslist.get(i).getDateformat()+ "</td><td style='width:50%'></td></tr>";
So, please guide me how solve this.
you need to use the getResources.getDrawable to get image in your code
ImageView img=new ImageView(this);
Drawable im= getResources().getDrawable(R.drawable.name);
img.setImageDrawable(im);
strBody += "<tr><td background="+img+ "style='word-break:break-all;width:50%;'>" + dslist.get(i).getBody()+"<br>"+ dslist.get(i).getDateformat()+ "</td><td style='width:50%'></td></tr>";