Is it possible to navigate directly to a child card? - gmail-addons

I have a list of root cards that I'd like to display on the home page of my add-on, but depending on the content of the email I'd like the add-on to open directly into a child card (but then allow the user to hit the back button to return to home).
What I want essentially is to be able to return a set of root cards in my onTriggerFunction, but then conditionally navigate the user to one of these cards

Yes that could be done. Lets say you have root1 burger, and root 2 fries card. And say both are capable of navigating to the child card using a button order where you need to fill out a form.
Now you must have written code to navigate to the order from like the following in both root cards.
var navToOrder = CardService.newNavigation().pushCard(leadAddCard);
return CardService.newActionResponseBuilder()
.setNavigation(navToOrder)
.build();
To conditionally open the child card use
return navToOrder when your condition is satisfied,
instead of returning the root card in the onTriggerFunction.

Related

Is it true that DIV elements cannot be clicked with selenium Web Driver?

Is it true that DIV elements cannot be clicked with selenium Web Driver?
For Instance, I'm unable to click on delete button in Gmail
Am trying to locate the elemnt using XPATH = //div[#aria-label='Delete']
here, class names and id's are dynamic which changes for every session. Imean, for every Login and Logout. I want my script to be Robust to run at any time.
You can by class name or ID, e.g. with class:
driver.findElement(By.className("class")).click();
Or by element name:
driver.findElement(By.ByTagName("div")).click();
Or find the parent or child a tag.
Have you tried using a different attribute ?
For e.g. you can use
//div[#data-tooltip='Delete']
or
//div[#data-tooltip='Delete']/div/div
It may derive because of gmail has async structure. You may wait to finish request after page load and after select action. If you can share code flow we can examine together.

How to find same logos, UI elements using sikulix

I am new to sikuli.
I am using it for functional test automation of my java spring standalone application. I am having the same set of images(logos) at multiple locations on the screen. and they are generated dynamically as per the application data. In that case how can I find and click on certain buttons/elements in the UI.
Example: like, share, comment text/image will be there several times in facebook page. in that how to we click on particular buttons out of all.(facebook is just an example) i want the similar solution for my application.
I think what you're asking is- given a case where the same image or UI element is present multiple times on the same page, how can I specify one of these elements in one location versus the same element in another?
The quick and easy way to do this would be to capture a larger picture, like as much of the window as you can, and click the image in parentheses after the click action; this opens a window reading file, matching preview, and target offset. Click target offset, use the mouse wheel to zoom in, and click on the exact point of the picture that you'd like to click.
It's possible to click in multiple places on a captured image, provided you use different click() commands, and you can set the target offset for each click() command without needing a new picture.
With just this one image, you can potentially click every square on the board provided you take the time to set the offset for each of the 64 click() commands it'd take to do so. http://files.chesscomfiles.com/images_users/tiny_mce/cigoL/Chessboard.png
The more difficult solution would be setting up regions, and searching those regions for the matching pictures, but for what you're looking for this should- for more about regions and setting it up check links below. Cheers!
http://sikulix-2014.readthedocs.io/en/latest/index.html
Based on your FB example you could use setROI() to focus on the top post on the page (imagine a rectangle that covers a complete post on the news feed) from there I would loop:
if exists(profile pic):
click(like button)
elif exists(profile pic 2): # If you are testing more than one user
click(like button)
else : type(Key.DOWN) #repeat as needed
Getting the next post into the ROI may be tricky but using WHEEL_DOWN may help if you can adjust your lines traveled with each wheel click on your system.

incompatible type passed in as a parameter created by loading a GUI component.

I am having a problem with a UI that I am building in a Google Spreadsheet. I will First explain a little about how it works and than I will get to the problem. The UI is fairly simple program that connects to a SQL database, it allows users to create new records, Query, search, and render reports. I have created all the panels (eg the intro page, the create record) in the GUI builder. As the user navigates through the UI I swap out a Grid with the new panel that i want the user to see. For example on the intro page there is a create button when the user clicks the button the gird where there intro panel was is replaced by the create record panel. I have created two ways for the user query/search for data. The first way is to select a number range on the intro panel and click the Query button. This will than query the last 10 or so records into a GUI built Panel that I will call MainForm. The second way is to "search" for a job. On the intro page there is a search button when the user clicks with button it goes to a new page; the grid is switched to the search panel. On the new page/panel the user can put in some parameters to search for. After the user clicks the search button the program should load the search results into the MainForm in the same way as when you Query from the intro page. I have taken the whole function apart line by line, so i am sure that the issue has to do with loading the panel/Component. What i mean by that is these few lines of code.
var Component = app.loadComponent("MainForm");
var panel = app.createVerticalPanel().setSize("770px", "900px").add(Component);
app.getElementById("contentGrid").setWidget(0,0, panel);
But why would it load in one case, but not in another? Also it is not the method of loading the Component, rather it is the returning the panel/ Component.
To Summarize, When I load the Component with the query function it works, but when i load the Component in the search function I get and error: Incompatible type passed in as a parameter. Also I load the MainForm Component in two other functions as and it works most of the time, but some times I get the same error.
I think your approach is not ideal, load component is not supposed to be called multiple times. It would be far more efficient to get all your panels in the same compnent and play with visibility of each panel to show / hide them on demand. Each panel should be inserted in a vertical panel so that the "new panel" slips to its place when the "old one" hides.
An example of this approach is shown in this post to simulate tabs and could easily be adapted to your needs.
btw, this method is also very fast and responsive since the full UI is ready from the very beginning ;-)

UiApp cache vertical panel

Developing small app to record a set of 6 readings for monitoring purposes in 31 rooms. App will have two main views, one view to show list of buttons for each room where readings will be taken, a second view where the values will be entered for a particular room and then posted to a spreadsheet.
The process in mind here is click on button for a particular room, enter the data, return to button view to choose another room to enter the data for that room and then back to button view screen.
Since the button view will seldom change do I have any options for caching this view so that I do not have to run a function to rebuild it each time. I have this function
function createTGSRoomListButtons(sh, aData){}
That takes the list of rooms and builds a panel of buttons for selecting the different rooms.
The question that I have can the above function be run once to cobble together the UI, cached and the later simply be 'recalled'?
TO that some end the view where the data will be entered can this be partially cached so that with each rendering a reference to a specific room can be made.
New to Google Apps Script so not really sure how to properly determine my answer.
You can have multiple panels in an UI and play with visibility to show one or another... no need to cache any content since they remain unchanged in the process.
If I understood your use case well, the panel with specific room info would be modified according to spreadsheet data so in this case you won't need to cache values since they would be "reconstructed" each time. The trick to show/hide panel has been shown in this post with clientHandlersand multiple panels in a unique vertical panel to ensure that the visible panel is always at the right place.
A very simple way would be build the UI for the first time and then hide/unhide the buttons' panel each time using the setVisible() method of the panel

Using a single shared element across multiple partial views

I have a basic ASP.Net MVC 3 application which has a number of controllers and a number of actions (and subsequently views)
A common feature of the application is to show a pop-up dialog window for basic user input. One of the key features of this dialog process is a faded mask that gets shown behind the dialog box.
Each of these dialog window controls is in a separate Partial View page.
Now, some view pages may use multiple dialog boxes, and therefore include multiple partial views in them - which as is would mean multiple instances of the "mask" element.
What I am trying to find a solution for is to only need to create one instance of a "mask" element regardless of the number of dialog partial views I include, and then the script in each partial dialog will have access to this element (so basically it just needs to be on the page somewhere)
The only real idea I have come up with so far is to add the "mask" element to the master page (or in the original view page) and this will mean it only gets added once. The problem here is that it will be added even when it is not needed (albeit one small single element)
I can live with this, but I would like to know if there is a better way to handle these kinds of scenarios?
A quick idea that came to mind is some kind of master page inheritance hierarchy, So I may have a DialogMasterPage that inherits from the standard current master page. How does that sound for an approach?
Thanks
To do something like this, where each module can register their need for a certain thing in the master page, you can use HttpContext to store a flag of whether you need to write the mask div, and just set that property in each partial. At the end of the master page, if the flag is set, you can then write the mask div if its set to true.
Obviously to make this cleaner you could wrap it all in an HtmlHelper extension or something.
My initial thought is for you to use something like jQuery UI where it handles the masking for you or if you are using something custom you can load the content for the dialog via ajax then show it in the single dialog on the master page.