Skip to content

Commit 9730bf0

Browse files
et priority to generate locators
Co-authored-by: SrinivasanTarget <[email protected]>
1 parent 86739e2 commit 9730bf0

File tree

3 files changed

+28
-3
lines changed

3 files changed

+28
-3
lines changed

src/resources/java/template.ts

Lines changed: 24 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,21 @@ export default function javaTemplatesResource(server: any) {
55
server.addResource({
66
uri: 'generate://code-with-locators',
77
name: 'Generate Code With Locators',
8-
description: `Generate code for the current page with locators which was retrieved from generate_locators tool.
8+
description: `Generate code for the current page with locators which was retrieved from generate_locators tool.
9+
The code should be generated in the same priorty order as the locators were generated.
10+
For iOS the priority order is:
11+
'id',
12+
'accessibility id',
13+
'-ios predicate string',
14+
'-ios class chain',
15+
'xpath',
16+
'class name',
17+
For Android the priority order is:
18+
'id',
19+
'accessibility id',
20+
'xpath',
21+
'-android uiautomator',
22+
'class name',
923
which follows the page factory pattern. Dont not strictly create test cases, just generate the code for locators.`,
1024
mimeType: 'text/plain',
1125
async load() {
@@ -30,6 +44,7 @@ import java.time.Duration;
3044
/**
3145
* This class demonstrates using PageFactory with Appium for cross-platform
3246
* mobile app locators using @AndroidFindBy and @iOSXCUITFindBy annotations.
47+
* Example:
3348
*/
3449
public class locators {
3550
@@ -42,8 +57,16 @@ public class locators {
4257
*/
4358
@AndroidFindBy(accessibility = "username_input")
4459
@iOSXCUITFindBy(accessibility = "username_input")
60+
61+
4562
public WebElement usernameField;
4663
64+
@iOSXCUITFindBy(iOSNsPredicate = "name = 'IntegerB'")
65+
private WebElement textField2;
66+
67+
@iOSXCUITFindBy(iOSClassChain = "XCUIElementTypeWindow/*/XCUIElementTypeTextField[2]")
68+
private WebElement secondTextField;
69+
4770
/**
4871
* Constructor that initializes the PageFactory
4972
*

src/tools/create-session.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -37,7 +37,7 @@ export default function createSession(server: any): void {
3737
.object({})
3838
.optional()
3939
.describe(
40-
'Optional custom capabilities for the session (W3C format). If not provided, default capabilities will be used based on the selected platform'
40+
'Optional custom capabilities for the session (W3C format).'
4141
),
4242
}),
4343
annotations: {

src/tools/select-platform.ts

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,9 @@ export default function selectPlatform(server: any): void {
77
server.addTool({
88
name: 'select_platform',
99
description:
10-
'REQUIRED: First select the mobile platform (Android or iOS) you want to work with before creating a session',
10+
`REQUIRED: First select the mobile platform (Android or iOS) you want to work with before creating a session,
11+
strictly and do not assume anything.
12+
This is mandatory and you must select one before proceeding to use the create_session tool.`,
1113
parameters: z.object({
1214
platform: z
1315
.enum(['ios', 'android'])

0 commit comments

Comments
 (0)