How to find multiple element in appium having same id in Python? - appium

I am writing test code in Appium of an Andriod Project in python . The problem is that I am not able to access two button in two different Activity having same Id . I have tried to access the second button in this way.But none of them works. How to resolve the issue?
driver.find_element_by_id("com.myapp.testApp:id/login[1]").click(), driver.find_element_by_class_name("android.widget.Button").click()
driver.find_element_by_xpath("(//button[#id='login'])[1]").click()
driver.find_element_by_xpath("//android.widget.Button[#text='Change Password']").click()

Use .find_elements*:
elements = driver.find_elements_by_xpath("xpath")
#check elements number
print(len(elements))
#click second element
elements[1].click()

Can you try with textview:
driver.find_element_by_xpath("//android.widget.TextView[#text='Change Password']").click()

If buttons texts are different, try by accessibility_id
driver.find_element_by_accessibility_id("Login").click()
driver.find_element_by_accessibility_id("Change Password").click()
OR
If you are familiar with uiautomator,
driver.find_element_by_android_uiautomator('new UiSelector().resourceId("com.myapp.testApp:id/login[1]")')
driver.find_element_by_android_uiautomator('new UiSelector().resourceId("com.myapp.testApp:id/login[2]")')

You can use the get method with findElements:
driver.findElements(By.xpath("yourXpath]")).get(0).click();

You can do link this, It will give you proper Output:
Input is:
d1 = driver.find_elements_by_id("com.application.zomato:id/price")
itemtotalprice = d1[0].get_attribute("text")
Here, is my output:
Mandarin Oak
₹200
₹166.75

Related

Vaadin 14 FlagItems not aligned correctly on ListSeries

I've got a problem regarding the FlagItem in Vaadin 14.
I'm trying to set a FlagItem for a specific point in a ListSeries, I'm doing this the following way:
PlotOptionsFlags plotOptionsFlags = new PlotOptionsFlags();
plotOptionsFlags.setOnSeries(wageEntry.getEmployeeCode());
plotOptionsFlags.setShape(FlagShape.SQUAREPIN);
plotOptionsFlags.getTooltip().setPointFormat("Wage: {point.y}");
plotOptionsFlags.getTooltip().setHeaderFormat("");
plotOptionsFlags.setShowInLegend(false);
DataSeries flagsSeries = new DataSeries();
flagsSeries.setName(wageEntry.getEmployeeCode().concat(" Current Wage"));
flagsSeries.setPlotOptions(plotOptionsFlags);
for (WageEntry wage : employeeWageEntries) {
if (wage.getWageYear() == LocalDate.now().getYear()) {
flagsSeries.add(new FlagItem(wage.getAge() - 22, wage.getEmployeeCode().concat(" - ").concat(String.valueOf(wage.getWageAmount()))));
}
}
comparisonChartConfiguration.addSeries(flagsSeries);
As you can see, I set the x value relative to the age of an entry, and the text. More over the FlagItem is only created when a certain condition is met. (I used the Vaadin Chart Demo as reference: https://demo.vaadin.com/charts/Flags)
The problem now is, that when the chart is being built, the FlagItem appear on the x axis instead as you can see here:
I really don't understand why this happens.
Maybe it's useful to know, that on the chart three RangeSeries and multiple ListSeries are being drawn.
Thanks for the help!
So I've found out where the problem was. It was something that wasn't added to the code above, so please have mercy.
The issues lied withing the fact that I didn't add the ListSeries to the comparisonChartConfiguration before creating the flagsSeries.
In short, you need to add the Series you want to append flags on to the ChartConfiguration before you can attach the flagsSeries onto another.

How to add page numbers to the header of a word document using Delphi xe5

I would like to be able to add the page numbers in a word document to the header.
I have found some links that display the code in visual basic, but no matter what i try, i keep getting errors. It keeps telling me the either "sections" or "headers" or "footers" is not a supported automation object.
Any help would realy be great. Thank You.
Links:
http://blogs.technet.com/b/heyscriptingguy/archive/2006/05/10/how-can-i-add-centered-page-numbers-to-the-footer-of-a-word-document.aspx
http://msdn.microsoft.com/en-us/library/office/ff194253(v=office.14).aspx
I Tried addapting the link's code with no success:
wrdDoc.ActiveDocument.Sections(1).Headers(wdHeaderFooterPrimary).PageNumbers.Add
and if possible please how to allign the page number right.
Use [] instead of () for indexes
//Headers[wdHeaderFooterPrimary] = Headers[1]
//Add possible values:
//wdAlignPageNumberCenter = 1
//wdAlignPageNumberInside = 3
//wdAlignPageNumberLeft = 0
//wdAlignPageNumberOutside = 4
//wdAlignPageNumberRight =2
wrdDoc.Sections[1].Headers[1].PageNumbers.Add(1); //example with center alignment
wrdDoc.Sections[1].Headers[1].PageNumbers.Add(2); //example with right alignment

zf2 How to Select Where Like Upper case

I trying to get some title from my database. But it doesn`t works:
$select->where->like('LOWER(title)','%'.$search_by.'%');
without LOWER it works fine.
$select->where->like('title','%'.$search_by.'%');
but I need LOWER case.
like() only seems to accept an identifier as its first parameter.
You should try this
$select->where->literal('LOWER(title) LIKE "%'.$search_by.'%"');
// or
$select->where->expression('LOWER(title) LIKE ?', '%'.$search_by.'%');
I have found a solution (in ZF3) for people who searched for:
use Zend\Db\Sql\Expression;
$upperExpr = new Expression('LOWER(?)', [title], [Expression::TYPE_IDENTIFIER]);
$select->where->like($upperExpr, "%" . mb_strtolower($search_by, 'UTF-8') . "%");
Or only strtolower() if you have no 'äÄöÖüÜ' ;)
This will create the right SQL-Statement.

How can i get a value of read only mode text box using webdriver...I tried with gettext but it is not working

Can any one help on this
How can i get a value of read only mode text box using webdriver...I tried with gettext but it is not working....
i gave a code as below
String Streetnumbercopare = driver.findElement(By.id("ctl00_ctl00_ContentPlaceHolder1_ContentPlaceHolderInNestedMP_uclRiskInfo_txtStreetNumber")).getText();
if (StreetNumberTextValue.equals(Streetnumbercopare)) {
System.out.println("Streetnumber matches --- Pass");
}else {
System.out.println("Street number doesn't match --- Fail");
}
I hade the same problem in python(using pytest)
If you also using python:
Try
element.get_attribute('value')
it works for me
Try driver.findElement(By.id("ctl00_ctl00_ContentPlaceHolder1_ContentPlaceHolderInNestedMP_uclRiskInfo_txtStreetNumber")).getAttribute("value")
You might have HTML like here: input tag example

OpenLayers print map

How can I print a map from the OpenLayers? I want to add print button in my OpenLayers page =) I have MapFish extension for my geoserver, but don`t know how to make request to it. Any other ideas are welcome) Help please.
I had a similar problem using a reverse proxy, because I discovered the answer from info.json contais local ip reference instead of the public url
to solve brutally i replaced the ip referenze with the public url in the ajax request (see the following code. I hope it can be usefull for others...
this.capabilities.createURL = this.capabilities.createURL.replaceAll("192.168.0.0:8080", "mypublicurl");
this.capabilities.printURL= this.capabilities.printURL.replaceAll("192.168.0.0:8080", "mypublicurl");
Ext.Ajax.request({
url:this.capabilities.createURL,
jsonData:jsonData,
success:function(response){
response.responseText = response.responseText.replaceAll("192.168.0.0:8080", "mypublicurl");
window.open(Ext.decode(response.responseText).getURL);
}
});
The simplest way is to use GeoExt.PrintMapPanel (geoext example). And be sure to read GeoServer Printing Module.
UPD GET request example. You must modify url, "baseURL", "layers". If you specify an existing layer, this request must return pdf file.
http://demo.opengeo.org/geoserver/pdf/print.pdf?spec={"units":"degrees","srs":"EPSG:4326","layout":"A4","dpi":75,"mapTitle":"Printing Demo","comment":"This is a simple map printed from GeoExt.","layers":[{"baseURL":"http://demo.opengeo.org/geoserver/wms","opacity":1,"singleTile":true,"type":"WMS","layers":["topp:tasmania_state_boundaries"],"format":"image/jpeg","styles":[""]}],"pages":[{"center":[146.56000000001,-41.56],"scale":8192000,"rotation":0}]}

Resources