Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Update time #14

Closed
wants to merge 21 commits into from
Closed
Show file tree
Hide file tree
Changes from 5 commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
69 changes: 69 additions & 0 deletions conf/wdio.conf.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,69 @@
const browser = (process.argv[5] || 'Chrome');
// const WdioCaptureIt = require('lambdatest-test-case-analytics').default;
let date = new Date();

// convert to IST
let istDate = new Date(date.toLocaleString('en-US', {timeZone: 'Asia/Kolkata'}));

let year = istDate.getFullYear();
let month = ('0' + (istDate.getMonth()+1)).slice(-2); // months are zero indexed
let day = ('0' + istDate.getDate()).slice(-2);
let hours = ('0' + istDate.getHours()).slice(-2);
let minutes = ('0' + istDate.getMinutes()).slice(-2);
let seconds = ('0' + istDate.getSeconds()).slice(-2);

let timestamp = `${year}-${month}-${day} ${hours}:${minutes}:${seconds}`;

exports.config = {
services: [
['lambdatest-test-case-analytics', {}],
// [WdioCaptureIt, {}],
[
"lambdatest",
{
tunnel: false,
lambdatestOpts: {
logFile: "tunnel.log"
}
}
]
],
user: process.env.LT_USERNAME,
key: process.env.LT_ACCESS_KEY,
buildName: process.env.LT_BUILD_NAME,
specs: ["./tests/specs/ATXtest.js"],
exclude: [],

capabilities: [
{
"LT:Options": {
browserName: browser,
version: "latest",
name: "TestCase Insights test",
// build: "Test Case Insights ATX n=1, 3 testcases try5",
// build: "Test Case Insights ATX n=2, 6 testcases try11",
build: `TestCase_Insights_build_${timestamp}`,
// build: "Test Case Insights ATX n=20, 60 testcases try2",
visual: true,
tags: ["ATX-testCaseInsights"],
console: true,
network: true,
platformName: process.env.HYPEREXECUTE_PLATFORM || 'windows 10'
// platformName: process.env.HYPEREXECUTE_PLATFORM || 'MacOS Catalina'
}
}],
logLevel: "info",
coloredLogs: true,
screenshotPath: "./errorShots/",
waitforTimeout: 100000,
connectionRetryTimeout: 90000,
connectionRetryCount: 1,
path: "/wd/hub",
hostname: "hub.lambdatest.com",
port: 80,
framework: "mocha",
mochaOpts: {
ui: "bdd",
timeout: 12000000
}
};
41 changes: 41 additions & 0 deletions package.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,41 @@
{
"name": "webdriverio-lambdatest",
"version": "0.1.0",
"readme": "WendriverIO Integration with [LambdaTest](https://www.lambdatest.com)",
"description": "Selenium examples for WebdriverIO and LambdaTest Selenium Grid",
"scripts": {
"test": "npm run single && npm run parallel && npm run multiple",
"single": "./node_modules/.bin/wdio conf/single.conf.js",
"parallel": "./node_modules/.bin/wdio conf/parallel.conf.js",
"multiple": "./node_modules/.bin/wdio conf/multiple.conf.js"
},
"repository": {
"type": "git",
"url": "git+https://github.com/lambdatest/webdriverio-selenium-sample.git"
},
"keywords": [
"webdriverio",
"lambdatest",
"automation",
"selenium",
"tests"
],
"bugs": {
"url": "https://github.com/lambdatest/webdriverio-selenium-sample/issues"
},
"homepage": "https://github.com/lambdatest/webdriverio-selenium-sample#readme",
"dependencies": {
"wdio-lambdatest-test-case-analytics-service": "*",
"chai": "*",
"mocha": "*",
"webdriverio": "*",
"axios":"*"
},
"devDependencies": {
"@wdio/cli": "*",
"@wdio/local-runner": "*",
"@wdio/mocha-framework": "*",
"@wdio/sync": "*",
"wdio-lambdatest-service": "*"
}
}
1 change: 1 addition & 0 deletions rename.ps1
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
(Get-Content node_modules\wdio-lambdatest-service\build\constants.js) | Foreach-Object {$_ -replace 'https://api.lambdatest.com/automation/api/', 'https://stage-api.lambdatestinternal.com/automation/api/'} | Set-Content node_modules\wdio-lambdatest-service\build\constants.js
137 changes: 137 additions & 0 deletions tests/specs/ATXtest.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,137 @@
describe('Test Case Insights Test', () => {
const n = 2; // change this to the number of test cases you want
let anyTestFailed = false;

beforeEach(() => {
browser.setTimeout({ 'implicit': 10000 }); // Set the implicit wait timeout to 10 seconds
});

afterEach(function() {
if (this.currentTest.state === 'failed') {
anyTestFailed = true;
}
});

after(async function() {
if (anyTestFailed) {
await browser.execute('lambda-status=failed');
} else {
await browser.execute('lambda-status=passed');
}
});
function delay(ms) {
return new Promise(resolve => setTimeout(resolve, ms));
}

for (let i = 1; i <= n; i++) {
let date = new Date();
let timestamp = `${date.getHours()}:${date.getMinutes()}:${date.getDate()} ${date.getSeconds()}:${date.getMonth() + 1}:${date.getFullYear()}`;

// it(`should login to LambdaTest #testCase${i}_${timestamp}`, async () => {
it(`should login to LambdaTest #testCase`, async () => {
await browser.url('https://stage-accounts.lambdatestinternal.com/login');
const emailField = await $('#email');
await emailField.setValue('18_apr@ltqa.lambdatestautomation.com');
// await emailField.setValue('19_apr@ltqa.lambdatestautomation.com');
// await emailField.setValue('24_apr@ltqa.lambdatestautomation.com');
// await emailField.setValue('27_mar@ltqa.lambdatestautomation.com');
// await emailField.setValue('28_apr@ltqa.lambdatestautomation.com');
await delay(2000);
// await emailField.setValue('abc@xyz.com');
// await passwordField.setValue('123');
const passwordField = await $('#password');
await passwordField.setValue('12345678');
await delay(2000);
const loginButton = await $('#login-button');
await loginButton.click();
await delay(2000);
await browser.url('https://stage-accounts.lambdatestinternal.com/dashboard');
const insightLink = await $("[class*='item__insights']");
await insightLink.click();
await delay(2000);
});

// it(`should perform search and open first dashboard #testCase${i}_${timestamp}`, async () => {
it(`should perform search and open first dashboard #testCase`, async () => {
const searchField = await $('#search');
await searchField.setValue('Sanity');
await delay(3000);
const textData = await $("[class*='divide-y divide-gray-200']>:nth-child(1)");
await delay(2000);
await textData.click();
await delay(2000);
});

it(`should logout from LT and open youtube #testCase`, async () => {
// await browser.execute('window.scrollTo(0,document.body.scrollHeight)');
await delay(2000);
const accountButton = await $('#profile__dropdown__parent');
await accountButton.click();
const logout = await $('#app__logout');
await logout.click();
await delay(2000);
await browser.url('https://www.youtube.com/');
// await browser.execute(`smartui.takeFullPageScreenshot,{"screenshotName":"LT-ATX","smartScroll":false}`);
});

it(`Todo Test #testCase`, async () => {
await browser.url("https://lambdatest.github.io/sample-todo-app/");

// Click on the first 5 items
for(let i=1; i<=5; i++) {
const item = $(`[class="list-unstyled"]>:nth-child(${i})>input`);
await item.click();

}

// Add n number of items and click on them
const n = 5; // The number of items you want to add
for(let i=1; i<=n; i++) {
const addvalue = $('#sampletodotext');
await addvalue.setValue(`Item ${i+5}`); // Added to existing 5 items
const addButton = $('#addbutton');
await addButton.click();

// Click on the added item
const newItem = $(`[class="list-unstyled"]>:nth-child(${i+5})>input`);
await newItem.click();
}
});


it(`Google Search #testCase`, async () => {
await browser.url("https://www.google.com");
const searchBox = $('[class="gLFyf"]');
await searchBox.click();
await searchBox.setValue('Lambdatest');
await browser.keys("\uE007"); // "\uE007" is the Unicode value for the "Enter" key
});


it(`Demo steps #testCase`, async () => {
await browser.url('https://www.lambdatest.com/automation-demos/');

const username = $('#username');
await username.setValue('lambda');
const password = $('#password');
await password.setValue('lambda123');
await browser.keys("\uE007"); // "\uE007" is the Unicode value for the "Enter" key
await delay(2000);
const displayPage = $('#developer-name');
// await displayPage.isDisplayed();
await displayPage.setValue('demo@lambdatest.com');
const random = $('[class="radio-button pb-20"]>:nth-child(5)');
await random.click();
const other = $('#others');
await other.click();
const checkbox = $('#tried-ecom');
await checkbox.click();
const textArea = $('#comments');
await textArea.setValue('Hi This is LambdaTest automation Demo');
const submit= $('[id="submit-button"]');
await submit.click();
});


}
});
32 changes: 32 additions & 0 deletions yaml/win/stage_testCaseInsights.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,32 @@
version: 0.1
globalTimeout: 90
testSuiteTimeout: 90
testSuiteStep: 90
# runson: mac
runson: win

autosplit: true
concurrency: 1
tunnel: false
cacheKey: '{{ checksum "package.json" }}'
cacheDirectories:
- node_modules
jobLabel: [ '${DATE}','ATX-testCaseInsights']
runtime:
language: node
version: "18"
preDirectives:
shell: powershell
commands:
- npm install
- cat node_modules\wdio-lambdatest-service\build\constants.js
- ls
- powershell ./rename.ps1
- cat node_modules\wdio-lambdatest-service\build\constants.js
testDiscovery:
type: raw
mode: dynamic
command: grep -lr 'describe' tests/specs/ATXtest.js
# command: cat test.txt
testRunnerCommand: npx wdio conf\wdio.conf.js --spec tests\specs\ATXtest.js
# testRunnerCommand: npx wdio conf/wdio.conf.js --spec tests/specs/ATXtest.js
29 changes: 29 additions & 0 deletions yaml/win/testCaseInsights.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
version: 0.1
globalTimeout: 90
testSuiteTimeout: 90
testSuiteStep: 90
# runson: mac
runson: win

autosplit: true
concurrency: 1
tunnel: false
cacheKey: '{{ checksum "package.json" }}'
cacheDirectories:
- node_modules
jobLabel: [ '${DATE}','ATX-testCaseInsights']
runtime:
language: node
version: "18"
preDirectives:
shell: powershell
commands:
- npm install
- cat node_modules\wdio-lambdatest-service\build\constants.js
testDiscovery:
type: raw
mode: dynamic
command: grep -lr 'describe' tests/specs/ATXtest.js
# command: cat test.txt
testRunnerCommand: npx wdio conf\wdio.conf.js --spec tests\specs\ATXtest.js
# testRunnerCommand: npx wdio conf/wdio.conf.js --spec tests/specs/ATXtest.js