salesforce / utam-java Goto Github PK
View Code? Open in Web Editor NEWUTAM Java implementation
License: MIT License
UTAM Java implementation
License: MIT License
Can I please get documentation or a user guide that helps set up the utam compiler for the selenium java automation framework? The readme of the repo is providing instructions to set up the project but really doesn't speak about the instructions to use the framework. I am looking for steps to create a .json file, right path to create .json files, and how to use the compiler to create Page Objects.
Thank you in Advance!
Just looking to see if theres possibility of having this project available in Python in the near future?
UtamBase.waitFor
does not provide options to explicitly set a timeout that differs from the globally configured timeout I set with UtamLoaderConfig.setExplicitTimeout
I would like UtamBase.waitFor
to be overloaded with same signature as Driver.waitFor
, so that I can specify a wait condition with a custom timeout for that wait operation.
Currently I'm increasing my global explicit timeout with UtamLoaderConfig.setExplicitTimeout
but this is increasing the overall test execution time when there is an error/failure in the test and the wait condition will never be true.
In some cases, I may want to wait a little longer (or shorter) than the global timeout. If an action is purely client side then a shorter wait could be appropriate, if action results in some external web service call and I need to wait for the results, then a longer wait time would be more appropriate.
I would like UtamBase
interface (and implementations) to include a waitFor
overload with additional options, similar to Driver.waitFor
e.g.
public interface UtamBase {
...
/**
* polling wait repeatedly applies expectations until truthy value is return (not null or boolean
* true)
*
* @param timeout timeout after which exception is thrown if condition is not met. If passed as
* null, timeout from config is used
* @param isTrue condition to apply
* @param message error message to throw if timeout is reached, can be null
* @param <T> return type
* @return result of the applied expectations
*/
<T> T waitFor(Supplier<T> isTrue, String message, Duration timeout);
...
}
Maybe use Selenium FluentWait
to achieve the same but then I'm jumping out of the UTAM abstractions. Alternatively I could use the UTAM Driver
but seems like there is no way to access that from a UtamBase
or the UtamLoader
.
On a side note, should UtamBase
and UtamLoader
have a public getDriver()
method?
I'm currently setting up UtamLoader
as follows:
final UtamLoader setupUtamLoader(WebDriver driver) {
var config = new UtamLoaderConfigImpl("utam-loader.config.json");
config.setExplicitTimeout(Duration.ofSeconds(90));
config.setImplicitTimeout(Duration.ZERO);
utamLoader = new UtamLoaderImpl(config, driver);
return utamLoader;
}
On windows i wanted to run
npm install utam --save-dev
npm install salesforce-pageobjects --save-dev
on a command prompt with local admin rigths.
The installation failed (see log extract below).
C:\>
so that i can create it manually to be able to install utam.Bug options
The installation should not fail. If a certain folder needs to be created an output stating the name of the folder that needs to be created including its path would be helpfull. The user could create the folder manually.
Set up a windows box where the user or certain processes have restricted rights to create folders on the main drive C:\>
See the log
npm install utam --save-dev
This is the logfile content from npm install utam --save-dev
0 verbose cli C:\Program Files\nodejs\node.exe C:\Users\<user-id>\AppData\Roaming\npm\node_modules\npm\bin\npm-cli.js
1 info using [email protected]
2 info using [email protected]
3 timing npm:load:whichnode Completed in 2ms
4 timing config:load:defaults Completed in 2ms
5 timing config:load:file:C:\Users\<user-id>\AppData\Roaming\npm\node_modules\npm\npmrc Completed in 3ms
6 timing config:load:builtin Completed in 3ms
7 timing config:load:cli Completed in 1ms
8 timing config:load:env Completed in 0ms
9 timing config:load:file:C:\.npmrc Completed in 1ms
10 timing config:load:project Completed in 2ms
11 timing config:load:file:C:\Users\<user-id>\.npmrc Completed in 1ms
12 timing config:load:user Completed in 1ms
13 timing config:load:file:C:\Users\<user-id>\AppData\Roaming\npm\etc\npmrc Completed in 0ms
14 timing config:load:global Completed in 0ms
15 timing config:load:setEnvs Completed in 1ms
16 timing config:load Completed in 12ms
17 timing npm:load:configload Completed in 13ms
18 timing config:load:flatten Completed in 3ms
19 timing npm:load:mkdirpcache Completed in 0ms
20 timing npm:load:mkdirplogs Completed in 0ms
21 verbose title npm install utam
22 verbose argv "install" "utam" "--save-dev"
23 timing npm:load:setTitle Completed in 1ms
24 timing npm:load:display Completed in 0ms
25 verbose logfile logs-max:10 dir:C:\Users\<user-id>\AppData\Local\npm-cache\_logs\2024-02-23T09_03_11_965Z-
26 verbose logfile C:\Users\<user-id>\AppData\Local\npm-cache\_logs\2024-02-23T09_03_11_965Z-debug-0.log
27 timing npm:load:logFile Completed in 10ms
28 timing npm:load:timers Completed in 0ms
29 timing npm:load:configScope Completed in 0ms
30 timing npm:load Completed in 59ms
31 timing arborist:ctor Completed in 1ms
32 timing command:install Completed in 15ms
33 verbose stack Error: EPERM: operation not permitted, mkdir 'C:\'
34 verbose cwd C:\dev\utam
35 verbose Windows_NT 10.0.19045
36 verbose node v18.7.0
37 verbose npm v9.7.1
38 error code EPERM
39 error syscall mkdir
40 error path C:\
41 error errno -4048
42 error [Error: EPERM: operation not permitted, mkdir 'C:\'] {
42 error errno: -4048,
42 error code: 'EPERM',
42 error syscall: 'mkdir',
42 error path: 'C:\\'
42 error }
43 error
43 error The operation was rejected by your operating system.
43 error It's possible that the file was already in use (by a text editor or antivirus),
43 error or that you lack permissions to access it.
43 error
43 error If you believe this might be a permissions issue, please double-check the
43 error permissions of the file and its containing directories, or try running
43 error the command again as root/Administrator.
44 verbose exit -4048
45 timing npm Completed in 579ms
46 verbose unfinished npm timer reify 1708678992517
47 verbose code -4048
48 error A complete log of this run can be found in: C:\Users\<user-id>\AppData\Local\npm-cache\_logs\2024-02-23T09_03_11_965Z-debug-0.log
npm install salesforce-pageobjects --save-dev
This is the logfile content from npm install salesforce-pageobjects --save-dev
0 verbose cli C:\Program Files\nodejs\node.exe C:\Users\<user-id>\AppData\Roaming\npm\node_modules\npm\bin\npm-cli.js
1 info using [email protected]
2 info using [email protected]
3 timing npm:load:whichnode Completed in 3ms
4 timing config:load:defaults Completed in 2ms
5 timing config:load:file:C:\Users\<user-id>\AppData\Roaming\npm\node_modules\npm\npmrc Completed in 4ms
6 timing config:load:builtin Completed in 4ms
7 timing config:load:cli Completed in 2ms
8 timing config:load:env Completed in 1ms
9 timing config:load:file:C:\.npmrc Completed in 1ms
10 timing config:load:project Completed in 2ms
11 timing config:load:file:C:\Users\<user-id>\.npmrc Completed in 1ms
12 timing config:load:user Completed in 1ms
13 timing config:load:file:C:\Users\<user-id>\AppData\Roaming\npm\etc\npmrc Completed in 1ms
14 timing config:load:global Completed in 1ms
15 timing config:load:setEnvs Completed in 1ms
16 timing config:load Completed in 15ms
17 timing npm:load:configload Completed in 15ms
18 timing config:load:flatten Completed in 4ms
19 timing npm:load:mkdirpcache Completed in 1ms
20 timing npm:load:mkdirplogs Completed in 1ms
21 verbose title npm install salesforce-pageobjects
22 verbose argv "install" "salesforce-pageobjects" "--save-dev"
23 timing npm:load:setTitle Completed in 6ms
24 timing npm:load:display Completed in 5ms
25 verbose logfile logs-max:10 dir:C:\Users\<user-id>\AppData\Local\npm-cache\_logs\2024-02-23T08_11_30_099Z-
26 verbose logfile C:\Users\<user-id>\AppData\Local\npm-cache\_logs\2024-02-23T08_11_30_099Z-debug-0.log
27 timing npm:load:logFile Completed in 40ms
28 timing npm:load:timers Completed in 0ms
29 timing npm:load:configScope Completed in 0ms
30 timing npm:load Completed in 113ms
31 timing arborist:ctor Completed in 0ms
32 timing command:install Completed in 14ms
33 verbose stack Error: EPERM: operation not permitted, mkdir 'C:\'
34 verbose cwd C:\dev\utam
35 verbose Windows_NT 10.0.19045
36 verbose node v18.7.0
37 verbose npm v9.7.1
38 error code EPERM
39 error syscall mkdir
40 error path C:\
41 error errno -4048
42 error [Error: EPERM: operation not permitted, mkdir 'C:\'] {
42 error errno: -4048,
42 error code: ' ',
42 error syscall: 'mkdir',
42 error path: 'C:\\'
42 error }
43 error
43 error The operation was rejected by your operating system.
43 error It's possible that the file was already in use (by a text editor or antivirus),
43 error or that you lack permissions to access it.
43 error
43 error If you believe this might be a permissions issue, please double-check the
43 error permissions of the file and its containing directories, or try running
43 error the command again as root/Administrator.
44 verbose exit -4048
45 timing npm Completed in 807ms
46 verbose unfinished npm timer reify 1708675890883
47 verbose code -4048
48 error A complete log of this run can be found in: C:\Users\<user-id>\AppData\Local\npm-cache\_logs\2024-02-23T08_11_30_099Z-debug-0.log
I've defined a cancel button in my page object as follows:
...
{
"name": "cancelButton",
"selector": {
"css": "lightning-button:nth-of-type(1)"
},
"type": "utam-lightning/pageObjects/button",
"public": true
},
...
I'm trying to click the lightning-button
on my page object, the button element implements the utam.core.element.Clickable
interface, so it has the click
method exposed. However, in the UI, the button element is being rendered within modal and the modal body has scrollbars so the buttons are not currently visible, as they are overlapped by the modal container. When the click()
method is called while the button is not visible an exception is raised: ElementClickInterceptedException
:
element click intercepted: Element <button class="slds-button slds-button_neutral" type="button">...</button> is not clickable at point (968, 786). Other element would receive the click: <div class="modal-container slds-modal__container" data-aura-rendered-by="982:0">...</div>
While debugging, I manually scrolled the modal body in the browser window and executed the click()
again and then it worked.
I was thinking I could compose a custom click method in my utam page object to scroll to the button element before clicking it.
However, currently only elements that implement the utam.core.element.Actionable
will have the methods scrollToCenter
and scrollToTop
exposed.
I think the Clickable
interface should also have these scrollTo*
methods?
Or maybe those methods should be pulled up the class hierarchy up to utam.core.element.BasicElement
or even utam.core.framework.UtamBase
so that any element could be scrolled to, not just those elements that are actionable / clickable?
utam-java v1.1.3
salesforce-pageobjects v2.2.0
A specific piece of markup in a LWC causes Java compilation of the utam.json file for that LWC to fail, and no Java class is compiled for that component. The compiler outputs an error relating to the generated function's signature.
The compiler error is not particularly clear, but this is what it prints:
46 > /**
47 > * method getFailure.id
48 > * @return idElement
49 > * @param index Integer
50 > */
51 >
52 > idElement getFailure.id(Integer index);
It's trying to create a function name of getFailure.id.
The code that's output is valid Java and the file generates.
Have a LWC with this piece of markup inside. In the markup, this is a list of errors. An individual error can be clicked to go to an associated element on the page (via the id value).
`
<ul class="slds-list_dotted">
<template for:each={failures} for:item="failure">
<li key={failure.id}>
<a data-position={failure.position} onclick={handleFailureClick} id={failure.id}
>{failure.message}</a
>
</li>
</template>
</ul>
`
On the command line in the repo, run utam-compile.js to generate a utam.json file for the LWC.
Compile the utam.json file into Java. I'm using the utam-compiler .jar for this.
A declarative, efficient, and flexible JavaScript library for building user interfaces.
๐ Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. ๐๐๐
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google โค๏ธ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.