i am trying to Scroll Using UIAutomator. The Scenario is I am entering the Settings menu in the tab and clicking on Apps options which gives me a list of all the apps in the tab. NOw i want to scroll the list of apps and this is where i am facing issues.It scrolls the Settings options and not the App list. I am attaching a screen shot and my piece of code.
UiScrollable scroll = new UiScrollable(
new UiSelector().scrollable(true));
scroll.setAsVerticalList();
UiObject Apps = scroll.getChildByText(new UiSelector()
.className(android.widget.TextView.class.getName()),
"Apps");
Apps.clickAndWaitForNewWindow();
UiObject Locker = scroll.getChildByText(new UiSelector().className(android.widget.TextView.class.getName()),"Content Locker");
Locker.clickAndWaitForNewWindow();
I am new to UiAutomator too and there is not very big amount of tutorials to learn it. I used Smrti example here, but some of the things already got deprecated, so I corrected it a bit to make everything work. Here's what I got
UiDevice mDevice = UiDevice.getInstance(getInstrumentation());
mDevice.pressHome();
UiObject allAppsButton = mDevice
.findObject(new UiSelector().description("Apps"));
allAppsButton.clickAndWaitForNewWindow();
UiScrollable appViews = new UiScrollable(new UiSelector().scrollable(true));
appViews.scrollIntoView(new UiSelector().text("Settings"));
mDevice.findObject(new UiSelector().text("Settings")).clickAndWaitForNewWindow();
mDevice.findObject(new UiSelector().text("Apps")).click();
I didn't include the search for certain app here, I'm sure you can manage it the same way as searching for the Settings app in my code snippet.
Say I want to click on App Facebook which is a little down the Apps list under Settings.
You can use this -
getUiDevice().pressHome();
allAppsButton = new UiObject(new UiSelector().description("Apps"));
allAppsButton.click();
appViews = new UiScrollable(new UiSelector().scrollable(true));
appViews.setAsHorizontalList();
selector = new UiSelector().className(android.widget.TextView.class.getName());
appToLaunch = appViews.getChildByText(selector, "Settings");
if (appToLaunch != null)
appToLaunch.clickAndWaitForNewWindow();
new UiObject(new UiSelector().text("Apps")).click();
UiScrollable appViews1 = new UiScrollable(newUiSelector().scrollable(true));
appViews1.scrollForward();
appViews1.scrollTextIntoView("Facebook");
new UiObject(new UiSelector().text("Facebook")).click();
This should work.
Related
I want to switch to to a new window on pressing a button, and the new window has dynamic URL, How do we handle this. Is there any workaround. I searched through many articles
Click the add button
cy.get('a[href*="javascript:xxxSearch();"]').click()
It opens a new window
I want to access(search/add the elements in new window and then switch back to previous main window
May be a good idea if you could share the full html of that page. As I understood from the question, may be grab the href and then get the attribute of href to a const and visit to that link as below. Just give a try and let me know if this is working for you.
it('Open a new window',function(){
cy.visit('some_url')
//test code continues....
cy.get('a[href="/some/link"]').then(($href)=>{
const hrefLink = $href.attr('href');
cy.visit(hrefLink);
// rest of you test to grab the search button
})
})
I am new to android and working on an app like dictionary.I am using search view from actionbar compat for searching suggestion and it is working good.
The problem is I want the search view on left aligned(where title shows) on actionbar and opened when the activity loads which is ok with normal devices but on tab it looks right aligned.
I have tried all the combination of showAsAction="" and setIconified() and setIconifiedByDefault() but not getting the desired result.
I want to use the default search view not custom if it is possible. I have searched a lot for this.
Is there any way(or link) by which i can get the desired output.
menu.xml:
android:id="#+id/action_search"
android:icon="#drawable/ic_action_search"
android:title="#string/action_search"
app:actionViewClass="android.support.v7.widget.SearchView"
app:showAsAction="always">
MenuInflater inflater = getMenuInflater();
inflater.inflate(R.menu.main, menu);
SearchManager manager = (SearchManager)getSystemService(Context.SEARCH_SERVICE);
searchView =(SearchView)enuItemCompat.getActionView(menu.findItem(R.id.action_search));
searchView.setSearchableInfo(manager.getSearchableInfo(getComponentName()));
searchView.setOnQueryTextListener(mOnQueryTextListener);
searchView.setIconified(false);
Thanks in advance...
I am actually trying to develop a Firefox extension using the high level apis, and specifically trying to avoid a panel to autohide when you pick a file or when you click outside of the panel itself.
Does somebody has an idea of how to do this?
I know that it is possible using XUL, so why is this not easy using the apis?
Thank you in advance for your answers.
This is the offical sdk method of doing it:
let myPanel = Panel({.....})
let { getActiveView }=require("sdk/view/core");
getActiveView(myPanel).setAttribute("noautohide", true);
Idea from
this
var toolbarbuttonPanel = doc.createElement('panel');
toolbarbuttonPanel.setAttribute('id', 'toolbarbutton-panel');
toolbarbuttonPanel.setAttribute('type', 'arrow');
toolbarbuttonPanel.setAttribute('noautohide', 'true'); // This is important
var toolbarbuttonLabel = doc.createElement('label');
toolbarbuttonLabel.setAttribute('value', 'toolbarbutton panel');
toolbarbuttonPanel.appendChild(toolbarbuttonLabel);
var mainPopupSet = document.querySelector('#mainPopupSet');
mainPopupSet.appendChild(toolbarbuttonPanel);
Then add this on sdk action/toggle button click:
toolbarbuttonPanel.openPopup(btn);
And Noitidart's comment
I have one main page with one button that directs my application to another page. When I click the button, the directed page should have gone to the address that I want on the Bing map. But I only see the world map. Here is the code of the second page:
public BingMapPage()
{
InitializeComponent();
BingMap.Mode = new RoadMode();
BingMapsTask bmt = new BingMapsTask();
bmt.SearchTerm = "Paris";
bmt.Show();
}
The code above only show the world map. However, if I write the same code in the constructor of the main page, it works as it is supposed to. Moreover, I tried to create a method in the second page as below:
public void StartSearch()
{
BingMapsTask bmt = new BingMapsTask();
bmt.SearchTerm = "Paris";
bmt.Show();
}
And then created an instance of my second page in the main page and called this method. It worked again.
My question is that is there a way of get these codes
bmt.SearchTerm = "Paris";
bmt.Show();
working outside of mainpage of an Windows Phone 7 application.
You cannot set the Searchterm to Paris. Searchterms are general terms like shops, businesses, hospitals etc. You may try an alternative approach. Create a webBrowser control and run the following line of code:
webBrowser.Navigate(new Uri("maps:<your address>"));
This will open the native maps app on the WP7 phone pointing to <your address>. I hope this was what you were looking for.
I'm using IsolatedStorageSettings on WP7 to store an objects list:
List<T>
I need to search an item inside my list and to update some properties of the searched item.
I'm using this code:
List<Article> listArt = null;
IsolatedStorageSettings.ApplicationSettings.TryGetValue("ArticleListStorage", out listArt);
var queryList = (from anItem in listArt where (anItem.Id == _id) select anItem).ToList<Article>();
a = queryList[0] as Article;
//mark Article as read
a.Readed = true;
When I continuously navigate the various page inside the app, I can see the property Readed correctly evalued.
But, when I click on WP7 Start button and reopen my app (without close emulator) I see the property not correctly evalued.
Need I to update my object inside list and so inside Isolated Storage?
Not updated by reference?
I tried also this, ant it doesn't work:
listArt[0].Readed = true;
listArt[0].Favorite = true;
IsolatedStorageSettings.ApplicationSettings["ArticleListStorage"] = listArt;
IsolatedStorageSettings.ApplicationSettings.Save();
What is wrong?
Thank you so much!
You can either explicitly call Save() on the settings or wait for the app to close normally and then they will be saved automatically.
As a general rule I'd suggest always explicitly saving settings once you change them. (Unless you have a very good reason not to.)
What's happening in your situation is that you are pressing the start button which causes your app to tombstone. When you launch a new instance of the app the tombstoned version is destroyed without all the code which normally runs on application close (including auto-saving settings) being executed.
Here's and example of using Save:
var settings = IsolatedStorageSettings.ApplicationSettings;
if (settings.Contains("some-key"))
{
settings.Remove("some-key");
}
settings.Add("some-key", "my-new-value");
settings.Save();
Yes, you've got to save your list again. Think of isolated storage as a file system - you wouldn't expect to be able to load an XDocument from disk, make changes in memory and automatically see those changes reflected on disk, would you? Well, it's the same with isolated storage.