Robotium Test case for android application - robotium

I want to automate a test case like.
I have two activities and in the first activity I am downloading the data from server and then I navigate to the second activity. so after coming back to first activity the state of the progress bar which i m using to show the download percentage should be retained/saved.
for this requirement I want to write a test case.Please suggest me a solution/example on design/code If you have.
Help is always appreciated, Thanks
Regards
Raghu

I suppose that you use a button with text to navigato to the second Activity, so you can try
solo.clickOnText("second activity");
solo.waitForActivity(YOUR_ACTIVITY_CLASS);
solo.goBack(); // back to the first activity
ProgressBar pb = (ProgressBar)solo.getCurrentActivity().findViewById(YOUR_PB_ID);
int progress = pb.getProgress(); // here you have the progressbar value
See more here: http://developer.android.com/reference/android/widget/ProgressBar.html#getProgress()

Related

ReadyAPI - Automation script to get the value from data source step

i am new to ReadyAPI and automation. But now i facing some issue where i wanted to fill in the consent page will the value that will get from the Data source.
The Role value is the value that i need to get and fill into the consent page
Here is my automation code to get the value:
I have to get the value from Data source, then fill into text box, then click button
This is the code im using:
document.getElementById('freeTextHabilitations').value = 'ObjectiveCombinaisons Data Source#Role';
document.getElementById('allowBtn').click();
I having problem where get nothing after the data source ran .
Anyone have any idea on how to inject the value from data source to automation script (java?)
Thank you.
Stanley,
Unclear as to how you are using DOM methods(with ReadyAPI), but to answer your question on accessing Data Source values
For that, you will need property expansion. So, your groovy script should be something like
xxxx.value = context.expand( '${ObjectiveCombinations Data Source#Role}' )
Property Expansion
This can be generated for you by using the Get Data dialog
Get Data Dialog

Scraping a page every time it changes

Hi I am currently looking to scrape a [age such as this "https://www.tennis24.com/match/ABiALWlt/#match-statistics;0" every time it changes score. currently i have the ability to scrape it using selenium and BS using the below code
from selenium import webdriver
Chrom_path = r"C:\Users\Dan1\Desktop\chromedriver.exe"
driver = webdriver.Chrome(Chrom_path)
driver.get("https://www.tennis24.com/match/zVrM3ySQ/#match-statistics;0")
data = driver.find_elements_by_class_name("statTextGroup")
for d in data:
sub_data = d.find_elements_by_xpath(".//*")
assert len(sub_data)==3
for s_d in sub_data:
print(s_d.get_attribute('class')[19:], s_d.get_attribute('innerText'))
but I have no idea how to automate it so that once the score at the top of the page located here"Medical timeout6 : 6 ( 0 : 0 )" changes, the scraper scrapes the new data. the change to monitor though is only visible when the match is in play and not always there.
if you need anymore info please let me know and ill be happy to add it
You can scrape in a while loop the "scoreboard"-class and when this is not the same as the old value of this then this value changed and you can scrape the other things you wanted.
Hope it helped

How to solve duplicate output by using search bar in ionic 4

I am using ionic 4. I want to do search function in my apps. I am using search bar and get the result from API.
My problem is it always output duplicate result.
One problem is I haven't typing the word finish it already match the result that I want to search, then it will output the result.
Another problem is when I finish typing it output again the result.
How can I solved or avoid this problem?
Here is my html code:
<ion-searchbar [(ngModel)]="name" (ionCancel)="onCancel($event)" (ionChange)="Search($event)"></ion-searchbar>
Here is my home.page.ts
Search() {
this.myService.getSearch(this.name);
}
The second one sounds like you are not wiping the data in your this.myService.getSearch call - check what it does in there, is it starting from a new list or just returning more results? If that doesn't solve that issue then post the code for that section.
The first issue is by design.
You can slow this down with the debounce option:
<ion-searchbar debounce="1500"></ion-searchbar>
There are two input events you can experiment with ionChange and ionInput - they act differently but I cannot remember exactly which does which, you will have to try them both. A third option would be to handle neither of them and just use a submit button.

Selenium Google Trends Custom period

I am trying to get daily data from Google trends using Selenium.
Therefore, I need to Input the start and end date in both boxes. For the start date, I use the following which works fine:
elem4 = browser.find_element_by_class_name("md-datepicker-input")
elem4.clear()
elem4.send_keys("01/01/2018")
However, the second box has the same class name 'md-datepicker-input'.
Picking it via xpath also doesnt work...
Has anyone an idea how to select that box, clear it and input my data?
Example custom period
Here is the CSS that you should use for To date.
.custom-date-picker-dialog-range-to .md-datepicker-inpt
If you want to use xpath
//div[#class='custom-date-picker-dialog-range-to']//input[#class='md-datepicker-input']

destroy things switching between views

in my program I have 2 'screen', in the first there is a list and if I press an item I go to the second screen… and in the second screen there is a button to return in the first…
when I return in the fist I get this warning
WARN][Ext.Component#constructor] Registering a component with a id (`usernamelabel`)
which has already been used. Please ensure the existing
component has been destroyed (`Ext.Component#destroy()`.
in the controller i tried something like this:
itemUp: function (dataview, index, target, record, e, Opst ) {
Ext.Viewport.animateActiveItem({xtype: 'mytabpanel'},{ type: 'flip' );
var store = Ext.getStore('Customers');
store.clearFilter();
Ext.destroy(this.searchField);
Ext.destroy(this.clientsList);
}
but doesn't work.. how to destroy an entire 'screen'?
PS: if I run the program in iOS or android devices I see ever the same "theme"…
how to specialise the theme? (on my win phone 7.8 doens't works.. is normal?)
thanks a lot!!!
It's because you harcoded id: usernamelabel, so when you initiate it the second time, you'll get above warning message. You'll be safe if you use itemId