How to enter the text in the Text Field in Android Emulator Using Monkey runner - monkeyrunner

I am using monkey runner.
I have on Screen 1 and I need to fill the form of the page and submit.
I need to take the focus to the first field and need to enter the text.
How to give the focus to any text field or can i type any way?
Please let me know..
REgards,
Chandra

Yes, one can focus on a text field and type text in that field.
I did it using Python. Followings are relevant lines from my code:
import os, subprocess
import sys
import time
import random
import string
import re
from com.android.monkeyrunner import MonkeyRunner, MonkeyDevice
#connect to the device
device = MonkeyRunner.waitForConnection(99, "emulator-5554")
Then, launch the relevant activity and move to the text field using the press function.
device.press ('KEYCODE_DPAD_DOWN', MonkeyDevice.DOWN_AND_UP)# move down
Normally, when you reach a text field then focus is already there, but if it is not then click the field.
device.press ('KEYCODE_DPAD_CENTER', MonkeyDevice.DOWN_AND_UP)#click the field
Now, one can type the text using the type function.
device.type('text')

Related

Single dialog for "open file" and "create new document"

Is it possible to use some form of QFileDialog to get a native (MacOS) dialog like the one below, where besides selecting a file, the user can choose to create a new document? I believe I have read all available documentation on the topic, but I could not find an answer.
(Note: This is the initial pick-a-file-or-create-a-new-one from Keynote. I am trying to replicate this behaviour).
EDIT As requested, I include some code. THis is standard pyqt5 boilerplate.
import PyQt5
from PyQt5.QtWidgets import QApplication, QFileDialog
app = QApplication(sys.argv)
filedialog = QFileDialog(None)
filedialog.setDefaultSuffix("texd")
filedialog.setNameFilter("TeX Document Bundle (*.texd);; TeX Template Bundle (*.textemplate)")
filedialog.setOption(QFileDialog.ReadOnly)
selected = filedialog.exec()
if selected:
filename = filedialog.selectedFiles()[0]
print(filename)
print(selected)
return

Got "Run-time error '31602'" when running DoCmd.RunSavedImportExport

Try to create an one-click button to import multiple tables from Oracle. Following is the code behind the On Click event of the button (with one table for now):
Private Sub Command0_Click()
If Not IsNull(DLookup("Name", "MSysObjects", "Name='FCR_LABOR_COST_SUMMARY1'")) Then
DoCmd.DeleteObject acTable, "FCR_LABOR_COST_SUMMARY1"
End If
DoCmd.RunSavedImportExport ("Import-FCR_LABOR_COST_SUMMARY1")
End Sub
Encountered the an error "Run-time '31602': The specification with the specified index does not exist. Specify a different index. 'Import-FCR_LABOR_COST_SUMMARY1'." when running "DoCmd.RunSavedImportExport"
The source table does not have any index on it. No need to have any index on the target table. Look like Access is trying to enforce an index on the target table. Is there anyway to turn this off? I'm new to Access and VB, please provide advice and directions on how to resolve this. Thanks.
To save a specication follow this document:
Create an import or export specification
1. Start the import or export operation from Access.
2. The import and export wizards are available on the External Data tab. The import wizards are in the Import & Link group, and the export wizards are in the Export group.
3. Follow the instructions in the wizard. After you click OK or Finish, and if Access successfully completes the operation, the Save Import Steps or Save Export Steps page appears in the wizard.
4. On the wizard page, click Save import steps or Save export steps to save the details of the operation as a specification.
5. Access displays an additional set of controls. This figure shows the dialog box with those controls available.
6. The Save Import Steps dialog box
In the Save as box, type a name for the specification.
In the Description box, type a description to help you or other users identify the operation at a later time.
7. To create an Outlook task that reminds you when it is time to repeat this operation, click Create Outlook Task.
8. Click Save Import or Save Export to save the specification. Access creates and stores the specification in the current database.
9. If you clicked Create Outlook Task on either the Save Import Steps or Save Export Steps page of the wizard, an Outlook Task window appears. Fill in the details of the task and then click Save & Close.
If the saved import or export specification you choose for the Saved Import Export Name argument is deleted after the macro is created, Access displays the following error message when the macro is run:
The specification with the specified index does not exist. Specify a different index. 'specification name'.
From: https://support.office.com/en-us/article/runsavedimportexport-macro-action-41c366d8-524e-4c7e-847d-c2cf7abb2049

Creating a macro of mouse clicks

Is it possible to create an automated python script/macro for a series of mouse clicks? The goal is to open a webpage, click button to open upload data window, and finally hit save button to crate a process.I am thinking of something equivalent to automated VBA macros which are recorded as operations are performed on sheets.
In past I have used pyautogui package for this activity but it requires hard coding of co-ordinates for mouse click and hence tedious to code.
Maybe try to use selenium with python...
Check the docs and examples.
Any easy example would be:
from selenium import webdriver
from selenium.webdriver.common.keys import Keys
driver = webdriver.Firefox()
driver.get("http://www.python.org")
assert "Python" in driver.title
elem = driver.find_element_by_name("q")
elem.clear()
elem.send_keys("pycon")
elem.send_keys(Keys.RETURN)
assert "No results found." not in driver.page_source
driver.close()
To download a file with firefox try:
from selenium import webdriver
# To prevent download dialog
profile = webdriver.FirefoxProfile()
profile.set_preference('browser.download.folderList', 2) # custom location
profile.set_preference('browser.download.manager.showWhenStarting', False)
profile.set_preference('browser.download.dir', '/tmp')
profile.set_preference('browser.helperApps.neverAsk.saveToDisk', 'text/csv')
browser = webdriver.Firefox(profile)
browser.get("http://www.drugcite.com/?q=ACTIMMUNE")
browser.find_element_by_id('exportpt').click()
browser.find_element_by_id('exporthlgt').click()
Another option would be the usage of pythons webbrowser.
Automatetheboringstuff gives some good examples.

what is the component typ or the domain of a button in abap

i searched the web for some hours but could not found anything to the topic,
neither in english "abap component typ of button" nor in german "abap komponententyp Drucktaste".
I want to create a structure in the dictonary which should contain some buttons,
which i add into a Dynpro via the "Dict/Programmfelder-Fenster F6" in the Screen Painter and have access in a report via "TABLES: structurename" resp. class that handle the process after input (pai) for me.
The idea is to have full controll of all events and fields in a controller like in the Design Pattern Model View Controll (MVC).
*&---------------------------------------------------------------------*
*& Module STATUS_2000 OUTPUT
*&---------------------------------------------------------------------*
* text
*----------------------------------------------------------------------*
MODULE status_2000 OUTPUT. " PBO
SET PF-STATUS '2000'.
SET TITLEBAR '2000'.
caretaker->pbo( ).
ENDMODULE. " STATUS_2000 OUTPUT
*&---------------------------------------------------------------------*
*& Module USER_COMMAND_2000 INPUT
*&---------------------------------------------------------------------*
* text
*----------------------------------------------------------------------*
MODULE user_command_2000 INPUT. " PAI
caretaker->pai( EXPORTING
iv_ok_code = ok_code ).
ENDMODULE. " USER_COMMAND_2000 INPUT
The handling for the default events like BACK, CANCEL and END which could be set in the PF-STATUS of the Dynpro and data components like e.g. UNAME (user name) and WERKS which can be easy added to a structure in the dictionary works fine that way.
Thanks in advance for any help.
Ok, here we go. I've got a solution.
I found the following help in german http://help.sap.com/saphelp_banking80/helpdata/de/d1/802352454211d189710000e8322d00/content.htm the same exist in english http://help.sap.com/saphelp_banking80/helpdata/en/d1/802352454211d189710000e8322d00/content.htm
If you add e.g. char1 or char7 into your dictionary structure and you add it in the screen painter to the dynpro you have the possibility to transform it into a button which have then the behaviour of a regular button.
To transform the char-input-field after adding it to the screen you need to double click it. A Popup window will appear (Screen Painter: Attribute).
At the bottom there is a section called Attribute with three tabs (Dict, Program, Display).
In tab program deselect "Inputfield".
In Screen Painter in menu bar: edit > convert > Pushbutton
(the field should now changed its look)
In Popup window "Screen Painter: Attribute" in tab program deselect outputfield
set the name/lable of the button above in the field text and the function code in the field FktCode
Now you have a button which is part of your structure and can be observed in your class.

Override only the Description field of the Plone standard content type

I would like to ovverride only the "view" of the classic "description field" of the Plone standard content type (Document, Folder, blabla), cause I need to "structure" the text of this field with structured text like:
This is my description<br/>
with many lines<br/>
bla bla<br/>
Changing the template that renders the standard description field to convert newlines to breaks isn't hard, but will require a little care to avoid creating a security hole.
Override the skin layer kss_generic_macros.pt template, either in a theming product or the custom folder.
Then, you may use Products.PythonScripts.standard.newline_to_br to convert newlines to breaks. You'll need to insert the converted text with "structure" to prevent escaping of the breaks.
Since you'll be using "structure," you absolutely must also manually html escape the description (use html_quote from standard) before applying newline_to_br, or you'll create a vector for a XSS attack.
The key section of the macro, when fixed, might read:
<div metal:define-macro="description-field-view"
id="parent-fieldname-description"
tal:define="kss_class python:getKssClasses('description',
templateId='kss_generic_macros', macro='description-field-view');
pps modules/Products.PythonScripts.standard"
tal:condition="context/Description"
tal:attributes="class string:documentDescription$kss_class;">
<span metal:define-slot="inside"
tal:replace="structure python:pps.newline_to_br(pps.html_quote(context.Description()))">Description</span>
</div>
You really don't want HTML in the description field. This field is used in a number of places and expects plain text.
You are best using the approach above to add an additional field with a different name.
If you want to customize the description widget for all content types you could create an adapter using archetypes.schemaextender (notably the ISchemaModifier interface) like this:
from my.product.browser.interfaces import IMyProductLayer
from my.product.widgets import MyCustomWidget
from Products.ATContentTypes.interface.interfaces import IATContentType
from archetypes.schemaextender.interfaces import IBrowserLayerAwareExtender
from archetypes.schemaextender.interfaces import ISchemaModifier
class MyExtender(object):
# you could choose a more specific interface for a more fine grained override
adapts(IATContentType)
implements(IBrowserLayerAwareExtender, ISchemaModifier)
# this will limit out override to this browserlayer
layer = IMyProductLayer
def fiddle(self, schema):
# if you want to customize just the template of the original widget
# see links below
schema['description'].widget=MyCustomWidget(
label='...',
....
)
return schema
and then you can register it like this:
<adapter
factory=".extender.MyExtender"
provides="archetypes.schemaextender.interfaces.ISchemaModifier" />
Don't forget to register your browser layer IMyProductLayer or this adapter will never be used.
More info:
http://pypi.python.org/pypi/archetypes.schemaextender
http://weblion.psu.edu/services/documentation/developing-for-plone/fsd-extender/hiding-fields
https://svn.plone.org/svn/archetypes/MoreFieldsAndWidgets/Products.MasterSelectWidget (a custom widget example)
http://docs.plone.org/old-reference-manuals/plone_3_theming/buildingblocks/skin/templates/customizing-at-templates/customizing-widgets.html (customize just the template of a widget)

Resources