Published Solutions
-
Selenium IDE basics for testing APS applications
Original Publishing Date: 2020-01-22 Preface Selenium is one of the most robust and comprehensive solutions in browser automation. This thing has 2 main branches: IDE WebDriver WebDriver (and formerly, RemoteControl) is used in conjunction with Selenium libraries to control either a clean browser instance directly or any browser instance through (remote) Selenium Server. Some scarce information about WebDriver can be found in APS documentation. IDE is a Firefox-only addon (FF 30+ is recommended) that uses its own set of commands (although reminiscent of those of Selenium libs) to automate actions in the browser it's installed in. This KBA will only discuss IDE. What is a test? A test, in the context of this article, is an action sequence that is created to achieve some goal. Unlike test in the general sense, our test may not check any functionality, it may simply automate several repetitive actions. Actions in a test might include something like: Click a link or a button Type a text into text field Check a check box Why is this needed? Tests may help automate repetitive tasks that have to be carried out many times. Such tasks may include: Package deployment (PCP resource creation, RT creation or subscription provisioning) CCP/MyCP UI testing Package removal Just about anything you can come up with! Bottom line is that if you are doing something through the browser many times, you are better off automating it. How do I start? Download latest IDE addon from Selenium downloads page. As of this writing, 2.9.0 is the latest. When you are done, an icon with letters Se will be shown either on your Firefox toolbar or in a hamburger menu (you may want to drag it onto the toolbar). Pressing this button wil launch the IDE. Note: Installing the IDE will most likely install Formatter addons as well. If you like to keep your browser clean, they are safe to remove and are not needed for APS testing: Note: By default, IDE is pretty limited in terms of flow control (like branches or conditionals). I would recommend installing the extension for IDE which introduces commands like gotoif gotoLabel and label. You can download this extension user-extension.js. You need to place it somewhere locally and then set a path to it in Options > Options > General > Selenium Core extensions (user-extension.js) in IDE. How do I create tests? When first opening IDE you will be presented with an empty test case in an empty test suite. Unlike WebDriver, IDE has a useful feature that allows it to record user's actions as they do it in their browser. Here is a quick IDE UI breakdown: For a full description of elements on this UI, refer to Selenium IDE docs [1] at the end of the article. When you press the record button, each action you make in any browser tab will be recorded and added to the current test case (they will appear in test case panel): Note: Selenium tries to record every action you perform. However, it may sometimes make mistakes in its interpretation of your actions. Example: you may click a link because it says Instances (translated to command: clickAndWait("link=Instances")), Selenium may record this action as Press the 4th link on the page in a specific place (translated to command: clickAndWait("css=#somediv > a:nth-child(4)")). In these cases, you may manually select from a few available alternatives: Note: When recording, Selenium inserts commands above the selected row in the test case panel. If you accidentally move the selection somewhere other than the bottom, you may get unexpected results (your actions will be added in the wrong place). Always keep an eye out for which row is selected in the test case panel. In some cases, Selenium may not properly register the necessary action on its own (like what time to wait for availability of elements on the page). In this case, you will need to add the proper commands manually: Adding commands manually requires basic understanding of Web Technologies (DOM events, page lifecycle and readiness events and frames/iframes). Sometimes, it is best to find a test which already performs the function you need instead of trying to search for the solution yourself. Examples of such tests may be found at the bottom of this page. In addition to that, KBAs with APS Applications product may include such tests in attachments. In OSA, a general window with APS UI looks like this: In this picture, there are 4 frames in total (with their respective DOM/JS names). Whenever you click a link in the leftFrame, mainFrame will refresh its contents (most of the time). aps2-ui frame is the one where APS custom JS UI resides. Notice how tabs on the picture are not part of the APS UI and instead are generated by OSA navigation engine. You can also see that the Screen ID shows the ID directly from package APP-META.xml when we are on the APS UI screen. Billing follows the similar structure, but so far there are no APS frames there (so there are only 3 frames). One of the biggest challenges of creating tests is to get IDE to wait for the page to be fully loaded before starting to execute actions (failing to do that will cause commands to fail as well because elements will not be present). Commands that may help in this: waitForElementPresent waitForVisible clickAndWait Information about what this commands do is accessible from within the IDE itself (as shown on the picture above: Reference tab) The other challenge is to properly select the frame which holds the element you are trying to affect (click/edit, etc.). Sometimes browsers will preserve the current frame and therefore you may not be able to access the elements you expect (all locators are relative to currently selected frame). Relevant commands: selectFrame selectWindow As you will get better at this task, you may want to spot and remove unused actions from your tests that are sometimes left after recording (Selenium will, for example, record 2 commands when interacting with a dropdown menu: one is select, which is correct, and the other is click, which is useless and can be omitted). It is a good practice to keep your tests as minimal as possible, because failing unused commands will cause test case to fail and stop. How do I save tests? To facilitate sharing and retention of tests, IDE comes with built-in save feature. In addition to saving singular test cases, you can also save a bunch of tests by saving a whole test suite. IDE stores tests in HTML format. Note: You can rename tests through the test suite panel by right-clicking them and choosing Properties. How do I run tests? When you have opened a test case or a test suite, you can use one of the IDE controls to play either the whole suite one-after-another or a single test. The test will start to execute on the current active browser tab. When it runs, it will mark successful steps with the green color and failed ones with the red. Critical failures will cause the test to stop executing. After the test stops executing (through failure or success), its status will show up in the test stats section: The log at the bottom of the window will be filled with messages as the test progresses: In this log, you can find causes of errors, should they appear. Related links: [1]Official IDE documentation [2]Example Test: Deploying a site application From creating RTs to provisioning subscription, test starts on the APS package page and will work with any site application. It needs a service template named APS Siteapp and a customer named Customer to work correctly. [3]Example Test: Creating resources in PCP via custom JS UI Test starts on the VPS Offering Management application page. You need to alter parameters in store commands and have the endpoint ready. Note: Use Save As browser command to save HTML files for opening in IDE instead of directly opening them in browser. Internal content
-
[APS1 to APS2] How minimal APS2 external application should look like? What are the mandatory elements?
Original Publishing Date: 2020-01-22 Each package should have: APP-META.xml - filled in manually using specification APP-LIST.xml - generated automatically during building of the package schemas folder - containing either manually created schema files or automatically created by apsbuild if aps-php-runtime is used Generally a package that actually does something has two more directories: scripts - containing application endpoint scripts, so far should be placed manually on endpoint server ui - containing html/js code to show views to the user A more advanced package would have these directories as well: images - used to store application icon and screenshots i18n - contains localization files (more on localization) doc - contains built-in documentation such as provider's guide, deployment guide etc Generally an application should have at least two services: Main service installed in Provider Control Panel (implementing http://aps-standard.org/types/core/application/1.0) Main service installed in Customer Control Panel (it should plug into http://www.aps-standard.org/ui/service) Check Starter package from our Getting Started guide for a simple package with two services. Internal content
-
[APS1 to APS2] In APS1 we used classes to get specific data from account/user/POA, how should it be done in APS2?
Original Publishing Date: 2020-01-22 Symptoms In APS1 we had classes to tell APS controller which data should be used to automatically populate a setting, for example class="login" provided service user's e-mail, class="given-name" provided the name from the contact. Resolution In APS2 it is possible to access all data of account from UI, to get detailed information about all service users you need to create an aps/ResourceStore with this apsType: userstore = new ResourceStore({ apsType: "http://aps-standard.org/types/core/service-user/1.0", target: "/aps/2/resources/" }); The following request will be send to the controller: GET /aps/2/resources?implementing(http://aps-standard.org/types/core/account/1.0): [ { "aps": { "type": "http://parallels.com/aps/types/pa/account/1.0", "id": "4867bc2b-0542-4d96-bdef-1ad4aeef6e0b", "status": "aps:ready", "revision": 3, "modified": "2014-01-28T03:44:48Z" }, "addressPostal": { "countryName": "de", "extendedAddress": "", "locality": "test", "postOfficeBox": null, "postalCode": "123456", "region": "", "streetAddress": "asdfdf 12" }, "companyName": "Test Customer", "id": 1000005 } ] Note: there are two permission scopes, for more details check this article. The full list of built-in types can be found here. Internal content
-
Eclipse or PhpStorm APS applciation installation fails with error about xdebug.so module.
Original Publishing Date: 2020-01-22 Symptoms Eclipse or PhpStorm APS application installation fails with the error about xdebug.so module. Cause This error is caused by missing Xdebug PHP extension on endpoint host, to fix this issue you should install Xdebug extension manually. Resolution Detailed documentation about Xdebug installation you could find here: https://xdebug.org/docs/install In general, you need to follow two steps: Install extension with the command: pecl install Xdebug Add this extension to your PHP configuration: zend_extension="/usr/local/php/modules/xdebug.so" Please note that latest Xdebug version 2.5.5 support only PHPv5.5 and newer, and sandbox endpoint host has PHPv5.4 installed by default. To handle it, you could choose from two options: Upgrade PHP on endpoint host to version 5.5 or newer. (recommended, since PHPv5.4 is quite old already). Install older Xdebug version, like 2.4.1. There is an example how to upgrade PHP Internal content
-
Cannot connect to sandbox VPN: TLS key negotiation failed to occur within 60 seconds
Original Publishing Date: 2020-01-22 Symptoms VPN connection to apsdemo does not work. Connection hangs for a while and then fails. Log of the connection contains TLS error similar to this one: TLS Error: TLS key negotiation failed to occur within 60 seconds TLS Error: TLS handshake failed Cause Problem with VPN certificate. Resolution Go to your profile on dev.apsstandard.org and request a new VPN certificate (you may need to revoke your existing one first). The new certificate should be available shortly (in about 5 minutes or sooner). Download the new certificate and configure your VPN connection to use it. If that still does not work, there may be problems on the remote side (on the side of VPN infrastructure) at that time. Please submit a request to the APS Developer Support (make sure to include VPN logs and any other relevant infromation in your request). Internal content
-
Cannot access sandbox via SSH or 8080 port after VPN is connected
Original Publishing Date: 2020-01-22 Symptoms OpenVPN connection is successfully established and I can PING my sandbox via hostname, but I cannot open OSA Panel via port 8080. SSH and FTP also do not work. Moreover - PING to the sandbox returns IP from the 199.x range, but it should be 10.x range. Cause It is caused by the manner how Windows works with OpenVPN. When OpenVPN client creates VPN connection - it offers Windows to use suggested DNS in order to handle all corresponding requests via this DNS server. However, in the latest updates of Windows 8/10 such behavior is changed and, as a result, Windows rejects DNS server offered by OpenVPN (sometimes or every time) and proceeds using Primary DNS servers of current Internet connection. So requests sent to the apsdemo.org network cannot be correctly resolved. Resolution The easiest and the fastest way to workaround such WinowsOpenVPN interaction is defining Primary DNS server manually in the connection settings. Please set manually this DNS server IP: 10.112.0.11 (points to the dns.apsdemo.org) There is an example how to configure it for the Windows 8/10: Windows 8 configuration Windows 10 configuration It also might be beneficial to disable IPv6 on VPN or all network interfaces if you still cannot connect. Internal content
-
How to retrieve locale of the currently logged in user from an APS2 application
Original Publishing Date: 2020-01-22 Question I need to retrieve the language of the logged in user. How can I do this? Answer Locale is available as part of context and you can retrieve it from custom UI, for instance: console.log('User locale: ' + aps.context.locale); , it will return the user's locale in following form: User locale: en_US Internal content
-
How to debug APS 1.2 scripts?
Original Publishing Date: 2020-01-22 Symptoms How to debug APS 1.2 scripts on the sandbox? Cause Resolution You need to find out the server where the scripts were provisioned. Find out the attribute assigned to the resource of your application in Applications -> MyApp -> "Resource Types" tab -> MyApp resource -> Provisioning Attributes and find out the node with the same attribute in Infrastructure -> Hardware Nodes Log on the server via ssh. Find the script in the directory like below: /usr/local/pem/APS/scripts/103/3.1.0-3/scripts/configure.php You can add 'fwrite(SRTDERR, $myVar);' to track the variables. Using fwrite will not break script output in POA. ... $stderr = fopen('php://stderr', 'w'); fwrite($stderr, "\n my debug output\n"); fwrite($stderr, $myVar); ... Now you can run script with specified system variables. The variables can be retrieved from /var/log/poa.debug.log on the management node: [root@mn ~]# grep 'executing configuration script' /var/log/poa.debug.log [APS] executing configuration script for APS application with id 103:'SERVICE_ID=CloudFlareDomain' 'SETTINGS_app_instance_id=' 'SETTINGS_cf_email=test@test.com' 'SETTINGS_cf_enabled=on' 'SETTINGS_cf_password=*****' 'SETTINGS_cf_plus_enabled=on' 'SETTINGS_cf_sub_inclusion=example.com::www,blog,support' 'SETTINGS_customer_domain_name=select' 'SETTINGS_host_api_key=18b6fed6a2dc8f2b937dd9ab9ab' 'SETTINGS_poa_api_ip=172.11.5.181' 'SETTINGS_poa_api_port=8440' 'SETTINGS_poa_password=*****' 'SETTINGS_poa_user=admin' 'SETTINGS_subdomains_inc_list_1=www' 'SETTINGS_subscription_id=1000003' php -q 'configure.php' 'install' So you can create bash script with system variable you got from log and run it. Please note that POA does not store the passwords in a plain text. You will need to replace the '*' values with actual passwords: #!/bin/sh cd /usr/local/pem/APS/scripts/103/3.1.0-3/scripts 'SERVICE_ID=CloudFlareDomain' 'SETTINGS_app_instance_id=' 'SETTINGS_cf_email=test@test.com' 'SETTINGS_cf_enabled=on' 'SETTINGS_cf_password=myPassword' 'SETTINGS_cf_plus_enabled=on' 'SETTINGS_cf_sub_inclusion=example.com::www,blog,support' 'SETTINGS_customer_domain_name=select' 'SETTINGS_host_api_key=18b6fed6a2dc8f2b937dd9ab9ab' 'SETTINGS_poa_api_ip=172.11.5.181' 'SETTINGS_poa_api_port=8440' 'SETTINGS_poa_password=myPoaPassword' 'SETTINGS_poa_user=admin' 'SETTINGS_subdomains_inc_list_1=www' 'SETTINGS_subscription_id=1000003' php -q 'configure.php' 'install' php -q 'configure.php' 'install' Now you can run bash script: sh /usr/local/pem/APS/scripts/103/3.1.0-3/bash-script.sh result1000003status0 Array ( [i4] => 1000003 ) 0 => 1000003 my debug output Internal content
-
PHP $_ENV environmental variable is empty
Original Publishing Date: 2020-01-22 Symptoms Configuration / verification script that uses PHP $_ENV environmental variable does not work correctly. Cause The $_ENV variables are imported from the environment under which PHP is running, and depending on your setup. The $_ENV is empty. The array wasn't populated because of a setting in php.ini: ; This directive determines which super global arrays are registered when PHP ; starts up. If the register_globals directive is enabled, it also determines ; what order variables are populated into the global space. G,P,C,E & S are ; abbreviations for the following respective super globals: GET, POST, COOKIE, ; ENV and SERVER. There is a performance penalty paid for the registration of ; these arrays and because ENV is not as commonly used as the others, ENV is ; is not recommended on productions servers. You can still get access to ; the environment variables through getenv() should you need to. ; Default Value: "EGPCS" ; Development Value: "GPCS" ; Production Value: "GPCS"; ; http://www.php.net/manual/en/ini.core.php#ini.variables-order variables_order = "GPCS" Resolution Set the variables_order setting in the php.ini to "EGPCS". Internal content
-
Error message 'Statement that is supposed to always return result return empty resultset' when contacting APS controller from endpoint.
Original Publishing Date: 2020-01-22 Symptoms I'm trying to contact APS controller to get resources from endpoint but I'm getting this error: { "code": 500, "type": "APS::Util::Exception", "message": "Statement that is supposed to always return result return empty resultset. ' SELECT app_instance_id FROM aps_application_instances WHERE uuid = ?'" } Cause Certificate that is used for authentication belongs to an instance of application that was already removed from POA. Resolution Create a new application instance, APS controller will send the new certificate in headers (if you are using APS PHP runtime it will be placed for you in config folder) Internal content