I am using "java-client-5.0.4" version, I am unable to select image from gallery.
Here is my code
List<AndroidElement> galleryElements = driver.findElementsByClassName("android.widget.ImageView");
TouchAction t = new TouchAction(driver);
t.tap(galleryElements.get(0)).perform();
In this case you can use the resource-id
By selectPhoto = By.id("imageView");
driver.findElement(selectPhoto).click();
but here is a problem, it will always select the first image, for specific image selection you should use xpath with index
Use ArrayList and get all image list in that list. After that provide index of the arraylist you can select the any image:
ArrayList<WebElement> listImage=(ArrayList<WebElement>) driver.findElements(By.id("com.euradvance.classstars:id/image"));
System.out.println(listImage.size());
listImage.get(5).click();
Related
Elements which i need to click
Element loator
Hi I am trying to click checkbox.
the below is my code
from appium import webdriver
import time
from selenium.webdriver.common.action_chains import ActionChains
from selenium.webdriver.common.by import By
desired_cap = dict(
platformName="Android",
platformVersion="11",
deviceName="1234567",
appPackage="io.appium.android.apis",
appActivity="io.appium.android.apis.ApiDemos"
)
driver = webdriver.Remote("http://127.0.0.1:4723/wd/hub", desired_cap)
driver.find_element(By.XPATH, "//android.widget.TextView[#text='Accessibility']").click()
driver.find_element(By.XPATH, "//android.widget.TextView[#text='Accessibility Node Querying']").click()
time.sleep(2)
chk= driver.find_elements(By.XPATH, "//android.widget.CheckBox")
for i in chk:
if i == 2:
i.click()
By above code if i give i.click() i am able to click all checkboxes. But if i want to click single check box i am not getting solution.
Select an array of elements and tap on its index
elements = self.driver.find_elements(*locator)
elements[i].click()
i use ThreeLineAvatarListItem in kivymd and i'm wondering how you can use an image from an url,
when i use a local image it's working but when it's an url, i receive this message:
[ERROR ] [Image ] Not found
https://c1.scryfall.com/file/scryfall-cards/art_crop/front/0/1/01cb2a12-4c1c-413d-91b1-574e4a00e251.jpg?1581630415
the code i use is this one :
for row in result:
image = ImageLeftWidget(source=row[3])
items = ThreeLineAvatarListItem(text=row[0], secondary_text=row[1],tertiary_text=row[2])
items.add_widget(image)
lv.add_widget(items)
row[3] contains "https://c1.scryfall.com/file/scryfall-cards/art_crop/front/0/1/01cb2a12-4c1c-413d-91b1-574e4a00e251.jpg?1581630415"
is there a way to do that ?
thank you
Try defining your own version of ImageLeftWidget that uses AsyncImage instead of Image, like this:
class AsyncImageLeftWidget(ILeftBody, AsyncImage):
pass
Then use this class in your code in place of ImageLeftWidget.
So I'm trying to add Images to my Grid using an IndexedContainer with the following code:
//picture
String imgURL = (String)ds.child(PHOTO).getValue();//gets the image URL from the DB
System.out.println(imgURL);
ExternalResource picture = new ExternalResource(imgURL);
System.out.println(picture.getURL());
Image image = new Image(PICTURE, picture);
image.setHeight("5px");
item.getItemProperty(PICTURE).setValue(image);
Instead of getting the picture, I'm getting the toString() of the Image object. Both println print the correct URL. Also note that this works with Table but not with Grid. Any idea why?
If you want to display an image in a Vaadin Grid column, you need to set the ImageRenderer, see here paragraph ImageRenderer.
Example: Define your column like
grid.addColumn("picture", Resource.class).setRenderer(new ImageRenderer());
then add a resource as column value
grid.addRow(new ThemeResource("img/copernicus-128px.jpg"), "Nicolaus Copernicus", 1543);
In your case it is the ExternalResource. No need for the Image component.
I can not find a way to read the items in a UI ListBox object. I have search and found some methods like getItemCount() and getItemText() in the Google Web Toolkit but they are not available when using the object in a javascript.....
Any ideas?
You will have to pass the list-box widget trough a Server Side call to get the selected data out of it:
function doGet(){
var app = UiApp.createApplication();
var lb = app.createListBox();
lb.setName("calName") //name used to fetch selected result
.addItem("Text Option One", "1")//options for selection
.addItem("Text Option Two","");//first peram display text and second peram value
app.add(lb); // adds listbox to display
app.add(app.createButton("Click Me")//create button
.addClickHandler(app.createServerHandler("showResult") // Create server side execution to handel click
.addCallbackElement(lb))); // add list-boxas element to be passed to server as parameter
return app;
}
function showResult(e){
var app = UiApp.getActiveApplication();
var res = e.parameter.calName;//parameter name same as list-box name given
app.add(app.createLabel("Selected option is " + res));//displays selected option
return app;
}
just create test app and save a version, Use this code for application and view latest code after deploying it.
i need to get the current image opened after importing an image sequence to ImageJ.
As i need to save the overlay information to a text file bearing the name of the image
int number = imp.getImageStackSize();
if(number > 1)
{
ImagePlus check = imp.duplicate();
gd.removeAll();
gd.addMessage(check.getTitle());
gd.showDialog();
}
imp.gettitle returns the folder name the images were loaded from.
couldn't find any solution so far :(
Any way to find the text in the status bar would be appreciated..
it was a simple issue..
the name of the current image can be retrieved by the following piece of code..
fileName = imp.getImageStack().getShortSliceLabel(imp.getCurrentSlice());
Thanks everyone..