i want to create a page which have for example 12 containers on top of each other .. and when i click on next .. container number 12 will go and 11 is displayed .. and so on till i end all of them ..
Something similar to this screenshot:
the page will have 2 buttons .. next and previous .. so i can go to next or previous .. and so on
is there is a way to do this in flutter? plugin or something?
Related
I'm trying to click on an icon that appears on the page however despite trying everything I can think of I keep getting the following error:
waiting for selector "[aria-label="Comment"]"
selector resolved to 2 elements. Proceeding with the first one.
selector resolved to hidden <svg role="img" width="24" height="24" fill="#8e8e8e"…>…</svg>
attempting click action
waiting for element to be visible, enabled and stable
element is visible, enabled and stable
scrolling into view if needed
element is not visible
retrying click action, attempt #1
waiting for element to be visible, enabled and stable
element is visible, enabled and stable
scrolling into view if needed
done scrolling
element is not visible
retrying click action, attempt #2
waiting 20ms
waiting for element to be visible, enabled and stable
etc etc etc.
So it looks like the element is hidden although I can't see any sign of that in the html....attached.
Any help greatly appreciated.
enter image description here
shorter version
page.locator('svg[aria-label="Comment"] >> nth=1').click();
You can use nth locator's method to get second element:
page.locator('svg[aria-label="Comment"]').nth(1);
or shorter version:
page.locator('svg[aria-label="Comment"] >> nth=1');
Keep in mind that's zero-based numbering.
I am trying to define the print parameters as presets with AppleScript.
I managed to open the pdf file with acrobat, open the print panel and define the number of copies, but then I was unable to "click" on the "Stampante..." (image 1) and subsequent (image 2) buttons. I do not find what are the commands to act on the window. Do you have any suggestions
#apro file con acrobat
#definire posizione la prima volta del programma
tell application "Adobe Acrobat Reader DC"
activate application
#apro file creare percorso per file su temp
open file "giungete:users:corrado:desktop:201.188_001.pdf"
#uso pulsanti per eseguire comando
tell application "System Events"
tell window "201.188_001.pdf"
#apro stampa
keystroke "p" using command down
delay 1
#vado copie
keystroke tab
delay 0.1
keystroke tab
delay 0.1
keystroke tab
delay 0.1
#definisco copie
keystroke "120"
delay 0.1
keystroke tab
delay 0.1
#do invio
#keystroke return
end tell
end tell
end tell
image 1
image 2
The example AppleScript code, shown below, was tested in Script Editor under macOS Monterey with Language & Region settings in System Preferences set to Italiano — principale and Inglese (US) and worked for me without issue1.
1 Assumes necessary and appropriate settings in System Preferences > Security & Privacy > Privacy have been set/addressed as needed.
Assuming you are Italian, and with no disrespect intended, I am not sure how well you will understand my answer or why I coded the example AppleScript code in the manner I have, however, I will try to explain some of it.
If you have a document opened in Adobe Acrobat Reader DC and you bring up the Print dialog box, it is a modal window and as such can simply be addressed as window 1 and no need to necessarily use window "Print" in general. The same goes for e.g. window "201.188_001.pdf", it can simply be addressed as window 1, but to just print an opened document the document window does not need to be relevant in my example AppleScript code because of how it is coded.
As there are multiple pop up button being clicked on the second |Print| window I wrapped the code in a handler so they can be clicked by number or name and number or name of the menu item. Keep in mind that by number the menu separators count as an incremented number.
I am using a choose file command to select the target PDF document to open and print in Adobe Acrobat Reader DC. You can of course choose not to use it and just set the print thisFile command to e.g.: print file "giungete:users:corrado:desktop:201.188_001.pdf"
I have added comments through the example AppleScript code to help explain what is happening.
Example AppleScript code:
property |Copies| : "120"
property |Print| : "Stampa"
property |Show Details| : "Mostra dettagli"
set thisFile to ¬
choose file of type "com.adobe.pdf" with prompt ¬
"Choose a PDF document:" default location ¬
(path to documents folder) without invisibles
tell application id "com.adobe.Reader"
activate
ignoring application responses
print thisFile
end ignoring
end tell
tell application id "com.apple.systemevents"
tell window 1 of application process "AdobeReader"
-- ## First |Print| window. ##
repeat until its name is |Print|
delay 0.01
end repeat
-- # Set the number of copies to print.
set value of first text field of group 1 to |Copies|
-- # Clicking the |Printer...| button causes a
-- # ~5 second delay, therefore tab to it instead.
-- # Tested in macOS Monterey and it took 18 tabs
-- # from the default opening of the |Print| window,
-- # however, it needs to be checked manually in
-- # other versions of macOS first.
repeat 18 times
key code 48 -- # tab key
delay 0.01
end repeat
key code 36 -- # enter key
-- # Wait a moment for the second |Print| window.
delay 1
-- ## Second |Print| window. ##
-- # Make sure second |Print| window is expanded.
if (the name of its button 2) is |Show Details| then
click button 2
delay 1
end if
-- # Click and select on Preset:
my clickPopUpButtonMenuItem(2, 1)
delay 0.25
-- # Click and select on Layout:
my clickPopUpButtonMenuItem(3, 1)
delay 0.25
-- # Click the Print button on the second |Print| window.
click button 4
delay 0.25
-- ## First |Print| window. ##
-- # Click the Print button on the first |Print| window.
-- # Leave commented until testing is finished.
--click button 4
end tell
end tell
-- # Handler #
on clickPopUpButtonMenuItem(PopUpButton, MenuItem)
-- # PopUpButton - Can be either an integer or the name.
-- # MenuItem - Can be either an integer or the name.
-- # MenuItem - Menu separators count as an incremented number.
tell application id "com.apple.systemevents"
tell window 1 of application process "AdobeReader"
click pop up button PopUpButton
click menu item MenuItem of menu 1 of pop up button PopUpButton
end tell
end tell
end clickPopUpButtonMenuItem
Notes:
As previously mentioned I chose not to click the Printer... (Stampante...) button because of the ~5 second delay if clicked. I believe the delay is caused because the second |Print| window opens and it has to time out because the button clicked it is from the first |Print| window which is now actually window 2, not window 1, and this is why tabbing makes more sense to avoid the delay.
I also tested the example AppleScript code in macOS Catalina and it was 17 tab stops to the Printer... (Stampante...) button, not 18 like in macOS Monterey.
Keep in mind that the number of tabs will be different if you change any of the other setting in the first |Print| window and it was based on your "image 1" link in that the only default you changed was the number of copies. You can always choose to click the Printer... (Stampante...) button instead and wait the ~5 second delay. It would be click button 2 instead of the repeat loop.
UI Scripting is kludgy and prone to failure and can break easily from one version of macOS to another as Apple and developers continually changes things, e.g. the hierarchical UI element structure. Case in point, 17 tabs in macOS Catalina vs. 18 tabs in macOS Monterey in this particular use case, the first |Print| window in Adobe Acrobat Reader DC.
Add-on to address request in comment
Even though the question originally focused on Adobe Acrobat Reader DC, nonetheless, as the author of the OP asked in comments about doing it in Preview, here is some example AppleScript code for use in macOS Monterey and Preview.
I thought it would be an interesting contrast to the different hierarchical UI element structure of the Print dialog box between the two applications to under the same version of macOS and how fragile UI Scripting can be preforming the same basic task between two different applications. While this would work with Preview in macOS Big Sur and macOS Monterey, it will not in macOS Catalina as the hierarchical UI element structure for the Print dialog box differs slightly, as there is no splitter group 1 of sheet 1 of window 1.
Example AppleScript code:
-- # Example AppleScript code for use in macOS Monterey and Preview.
property |Copies| : "120"
property |Print| : "Stampa"
property |Show Details| : "Mostra dettagli"
set thisFile to ¬
choose file of type "com.adobe.pdf" with prompt ¬
"Choose a PDF document:" default location ¬
(path to documents folder) without invisibles
tell application id "com.apple.Preview"
activate
open thisFile
end tell
tell application id "com.apple.systemevents"
-- launch -- # Used in an attemp to workaround a bug.
-- # Used to see the full large print dialog if Preview opens
-- # the document too tight on the left side of the screen.
tell window 1 of application process "Preview"
set currentPosition to its position
if item 1 of currentPosition is less than 70 then ¬
set its position to {70, item 2 of currentPosition}
end tell
-- # Bring up the Print dialog box.
keystroke "p" using command down
-- # Wait until the Print dialog box is ready.
repeat until exists button 1 of ¬
splitter group 1 of sheet 1 of window 1 of ¬
application process "Preview"
end repeat
tell splitter group 1 of sheet 1 of window 1 of application process "Preview"
-- # Show Details if necessary. (Mostra dettagli)
if exists button |Show Details| then
click button |Show Details|
delay 1
end if
-- # Printer: pop up button. (Stampante:)
click pop up button 1
click menu item 1 of menu 1 of pop up button 1
-- # Preset: pop up button.
click pop up button 2
click menu item 1 of menu 1 of pop up button 2
-- # Copies: text field. (Copie:)
set value of text field 1 to |Copies|
-- # Paper Size: pop up button. (Dimensioni pagina:)
click pop up button 3
click menu item 5 of menu 1 of pop up button 3
click menu item 2 of menu 1 of menu item 5 of menu 1 of pop up button 3
-- # Preview pop up button (By default.) (Anteprima)
click pop up button 4
click menu item 1 of menu 1 of pop up button 4
delay 1
-- # The following will vary based on menu selection of pop up button 4.
tell group 3
click pop up button 1
click menu item 1 of menu 1 of pop up button 1
-- click pop up button 2
-- click menu item 1 of menu 1 of pop up button 2
-- click pop up button 3
-- click menu item 1 of menu 1 of pop up button 3
end tell
-- # Print button. (Stampa)
-- click button 4 -- # Or click by name.
click button |Print|
end tell
end tell
Note: The example AppleScript code is just that and sans any included error handling does not contain any additional error handling as may be appropriate. The onus is upon the user to add any error handling as may be appropriate, needed or wanted. Have a look at the try statement and error statement in the AppleScript Language Guide. See also, Working with Errors. Additionally, the use of the delay command may be necessary between events where appropriate, e.g. delay 0.5, with the value of the delay set appropriately.
Thanks for the answers. I followed your advice I am clear to me the command to use the problem is what the window opens is called!
Example link
if not (exists (1st window whose value of attribute "AXIdentifier" is "MessagesPreferencesWindow")) then
Then Identifies the window and now with a new version of messages the menus changed but work
this works !!! link
I always get and only
System Events ha trovato un errore: Impossibile ottenere window "201.188_001.pdf – 1 pagina" of window "201.188_001.pdf".
I downloaded ui browser and found the correct path but I always get error
thanks corrado
I am learning mobile automation and I came across a scenario some thing like this
Launch chrome app in iOS
Load https://www.google.com
Hold/Press and pull down banner web element on the web page which will display some overlay with three options 'New tab, Reload & Close tab' (note: overlay will lost on releasing the banner web element)
Tap on the new tab button
So far I have written below script in python
def Test(self, driver_provider):
single_tap = appium.webdriver.common.touch_action.TouchAction(driver_provider.driver)
element = driver_provider.driver.find_element_by_accessibility_id('NTPHomeFakeOmniboxAccessibilityID')
single_tap.tap(element=element).perform()
element.send_keys('https://www.google.com')
single_tap.tap(element=driver_provider.driver.find_element_by_accessibility_id('Go')).perform()
time.sleep(1)
#Press banner and pull down will display the over scroll actions
#Then move to left to tap on the add button
banner_element = driver_provider.driver.find_element_by_accessibility_id('banner')
screen_size = driver_provider.driver.get_window_size()
height = screen_size.get('height')
width = screen_size.get('width')
single_tap.press(banner_element, x=banner_element.size.get(
'width')/2, y=banner_element.size.get('height')/2).wait(1).move_to(banner_element,
x=width/2, y=height/2).wait(0.5).move_to(banner_element, x=0, y=height/2).release().perform()
for some reason press and move_to actions are not happening and there is no error returned as well, I am not clear what went wrong here. Please share your view on what went wrong thanks.
it's failing to perform press and move to because of wait value is very small. When I use the wait(500) then the press and move to is happening.
single_tap.press(banner_element, x=banner_element.size.get(
'width')/2, y=banner_element.size.get('height')/2).wait(500).move_to(banner_element,
x=width/2, y=height/2).wait(500).move_to(banner_element, x=0, y=height/2).wait(500).release().perform()
I create tests using Appium+Python to test IOs app.
I want to scroll the page.
Here is the code
def scroll_page(self):
action = TouchAction(self)
action.press(BrowsePageElements.firs_element_to_scroll(self)).
move_to(BrowsePageElements.second_element_to_scroll(self)).perform()
When I'm trying to run this function, I get an error
error screenshot
Could you help me to find out, how to fix this error?
Appium Python has a native scroll function. It works for both Android and iOS.
driver.scroll(origin_el, destination_el, duration=None), where duration is an optional argument. This function scrolls origin_el to the location of destination_el.
Link to scroll source code
The Appium documentation is rather spotty and needs updating. However, the source code is documented well enough to understand and learn the program.
This currently works for me:
...
SCROLL_DUR_MS = 3000
...
window_size = self.driver.get_window_size()
self.scroll_y_top = window_size['height'] * 0.2
self.scroll_y_bottom = window_size['height'] * 0.8
self.scroll_x = window_size['width'] * 0.5
...
def scroll_up(self):
self._y_scroll(self.scroll_y_top, self.scroll_y_bottom)
def scroll_down(self):
self._y_scroll(self.scroll_y_bottom, self.scroll_y_top)
def _y_scroll(self, y_start, y_end):
actions = TouchAction(self.driver)
actions.long_press(None, self.scroll_x, y_start, SCROLL_DUR_MS)
actions.move_to(None, self.scroll_x, y_end)
actions.perform()
It scrolls slowly over 3s because I want it to be controlled, but you could shorten SCROLL_DUR_MS (the duration of the scroll action in milliseconds) if you want something more zoomy. I also went away from using elements as the start and/or end points because I wanted something general that would work with any screen content.
For scroll_y_top and scroll_y_bottom I picked 20% in from the top and bottom of the screen just to make sure I wasn't hitting anything at the borders (like the navigation bar at the top of iOS Preferences or an info bar at the bottom of the app I was working in). I also ran into a "bug" where it wasn't scrolling when I left scroll_x as 0, but it turns out that it wasn't registering the left edge as inside the scrolling area for the app I was working in.
Hope this helps.
In the past when i've run into issues scrolling for one reason or another, I've simply swiped using coordinates to scroll down the page.
self.driver.swipe(100, 700, 100, 150)
Is there a keyboard shortcut in Xcode 4 to switch the build target destination; that is, to switch from simulator to device and vice versa?
There is, is called Destination>select next destination. Go in the prefs in xcode and then in the key bindings tab, search for that, it will show what key it is set at.
For me, is cmd+alt+ctrl+] and [ to switch. Is quite useful, saves a few seconds.
In Xcode 4.6, the shortcut is ctrl+option+cmd+[ and ctrl+option+cmd+]
You can use ctrl + cmd + [ or ctrl + cmd + ] to select scheme, or use ctrl + cmd + [alt] [ or ctrl + cmd + [alt] ] to select product
Or you can just search in the preference panel of key bindings for more information
You can write applescript and bind it to some hotkey (using FastScripts for example - free up to ten bindings).
Next script will click for you on your scheme button in the Xcode toolbar:
tell application "System Events"
tell process "Xcode"
click ((pop up buttons of list 1 of group 2 of tool bar 1 of front window) whose description is "Active Run Destination")
end tell
end tell
then you can just use Up/Down to switch destination.
Note that you need to enable access for assistive devices under the SystemPreferences -> Accessibility
You can go to the edit scheme menu with cmd+< which is actually cmd+shift+.
You should know
Build: cmd+B
Run: cmd+R
Test: cmd+U
Profile: cmd+I
Analyze: shift+cmd+B
But there isn't a command just to switch between the iPhone simulator, iPad simulator, and all of your external.
I have a slightly different problem but it might help you as well.
I have only one physical device which always stays at the top.
Its super simple to select top list device as a target.
Do:
pops up the list for target devices
CTRL + SHIFT + 0
takes you to the first device
CMD + UPARROW
selects that device
SPACE
Apple Script goes:
tell application "Xcode" to activate
tell application "System Events"
tell process "Xcode"
keystroke "0" using {control down, shift down}
delay 0.55
keystroke (ASCII character 29)
delay 0.55
keystroke (ASCII character 30) using command down
delay 0.55
keystroke (ASCII character 32)
delay 0.55
keystroke "r" using command down
end tell
end tell
Riffing on off Comradsky, the answer is then:
Cmd+Shift+, then Tab then Up/Down
You can also option-click on the scheme in the title bar to directly open the settings for the scheme (whereas a normal click opens the context menu that displays a list of all the schemes).
Show Destinations
To bring up the list of destinations use ⤵︎
^ + Shift + 0