0% found this document useful (0 votes)
231 views3 pages

VFS Global Appointment Automation Script

vvvvvvvvvvvvv kkkkkkkj

Uploaded by

alaabousmaha014
Copyright
© All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as TXT, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
231 views3 pages

VFS Global Appointment Automation Script

vvvvvvvvvvvvv kkkkkkkj

Uploaded by

alaabousmaha014
Copyright
© All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as TXT, PDF, TXT or read online on Scribd

// ==UserScript==

// @name VFS Global Appointment Automation


// @namespace [Link]
// @version 1.1
// @description Automate VFS Global appointment scheduling
// @match [Link]
// @match
[Link]
// @match
[Link]
// @grant none
// ==/UserScript==

(function() {
'use strict';

// Function to click a specific button on the Home/Index page


async function clickHomeIndexButton() {
[Link]('Attempting to click button on Home/Index page...');
await waitForElement('//*[@id="Accordion1"]/div/div[2]/div/ul/li[1]/a');
let homeIndexButton =
[Link]('//*[@id="Accordion1"]/div/div[2]/div/ul/li[1]/a', document,
null, XPathResult.FIRST_ORDERED_NODE_TYPE, null).singleNodeValue;

if (homeIndexButton) {
[Link]();
[Link]('Button on Home/Index page clicked');
} else {
[Link]('Button on Home/Index page not found');
}
}

// Function to click "Continue" button on Applicant List page


async function clickContinueOnApplicantList() {
[Link]('Attempting to click "Continue" on Applicant List...');
await waitForElement('/html/body/div[2]/div[1]/div[3]/div[3]/a');
let continueButton =
[Link]('/html/body/div[2]/div[1]/div[3]/div[3]/a', document, null,
XPathResult.FIRST_ORDERED_NODE_TYPE, null).singleNodeValue;

if (continueButton) {
[Link]();
[Link]('"Continue" button clicked on Applicant List');
} else {
[Link]('"Continue" button on Applicant List not found');
}
}

// Function to click "Submit" button on Applicant List form on the second visit
async function clickSubmitOnSecondApplicantList() {
[Link]('Attempting to click "Submit" on second visit to Applicant
List...');
await waitForElement('//*[@id="ApplicantListForm"]/div[2]/input');
let submitButton =
[Link]('//*[@id="ApplicantListForm"]/div[2]/input', document, null,
XPathResult.FIRST_ORDERED_NODE_TYPE, null).singleNodeValue;

if (submitButton) {
[Link]();
[Link]('"Submit" button clicked on second visit to Applicant
List');
} else {
[Link]('"Submit" button on second visit to Applicant List not
found');
}
}

// Function to fill in the applicant form


async function fillApplicantForm() {
[Link]('Filling in applicant form...');
await waitForElement('/html/body/div[2]/div[1]/div[3]/div[4]/form/div[1]/
div[2]/input');

let numberField =
[Link]('/html/body/div[2]/div[1]/div[3]/div[4]/form/div[1]/div[2]/
input', document, null, XPathResult.FIRST_ORDERED_NODE_TYPE, null).singleNodeValue;
let nameField =
[Link]('/html/body/div[2]/div[1]/div[3]/div[4]/form/div[3]/div[2]/
input', document, null, XPathResult.FIRST_ORDERED_NODE_TYPE, null).singleNodeValue;
let surnameField =
[Link]('/html/body/div[2]/div[1]/div[3]/div[4]/form/div[4]/div[2]/
input', document, null, XPathResult.FIRST_ORDERED_NODE_TYPE, null).singleNodeValue;
let selectField =
[Link]('/html/body/div[2]/div[1]/div[3]/div[4]/form/div[2]/div[2]/
select', document, null, XPathResult.FIRST_ORDERED_NODE_TYPE,
null).singleNodeValue;
let nationalityDropdown = [Link]('//*[@id="NationalityId"]',
document, null, XPathResult.FIRST_ORDERED_NODE_TYPE, null).singleNodeValue;
let nationalityOption =
[Link]('//*[@id="NationalityId"]/option[4]', document, null,
XPathResult.FIRST_ORDERED_NODE_TYPE, null).singleNodeValue;

if (numberField && nameField && surnameField && selectField &&


nationalityDropdown && nationalityOption) {
[Link] = '123456';
[Link] = 'Sifo';
[Link] = 'belkcm';
[Link] = [Link];
[Link](new Event('change'));
[Link]('Applicant form filled');
} else {
[Link]('Form fields or dropdown not found');
}
}

// Wait for an element to be available


function waitForElement(xpath) {
return new Promise((resolve, reject) => {
let interval = setInterval(() => {
let element = [Link](xpath, document, null,
XPathResult.FIRST_ORDERED_NODE_TYPE, null).singleNodeValue;
if (element) {
clearInterval(interval);
resolve(element);
}
}, 500);
});
}
// Main script execution
[Link]('load', async () => {
[Link]('Page loaded. Starting script...');

if ([Link]('Home/Index')) {
await clickHomeIndexButton();
}

if ([Link]('Applicant/ApplicantList')) {
if ([Link]('ApplicantList')) {
await clickContinueOnApplicantList();
await clickSubmitOnSecondApplicantList();
}
}

if ([Link]('AddApplicant')) {
await fillApplicantForm();
}
});
})();

You might also like