Skip to content

Commit

Permalink
Merge branch 'main' into testFixes
Browse files Browse the repository at this point in the history
  • Loading branch information
saikrishna321 authored Jan 7, 2025
2 parents 1884b35 + 31e38f6 commit adfb956
Show file tree
Hide file tree
Showing 25 changed files with 715 additions and 574 deletions.
2 changes: 1 addition & 1 deletion app/common/public/locales/ko/translation.json
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
{
"appiumInspector": "",
"appiumInspector": "Appium Inspector",
"Edit": "변경",
"Redo": "재실행",
"Cut": "자르기",
Expand Down
6 changes: 3 additions & 3 deletions app/common/renderer/actions/Inspector.js
Original file line number Diff line number Diff line change
Expand Up @@ -562,7 +562,7 @@ export function setLocatorTestElement(elementId) {
location: {x: commandRes.x, y: commandRes.y},
size: {width: commandRes.width, height: commandRes.height},
});
} catch (ign) {}
} catch {}
}
};
}
Expand Down Expand Up @@ -817,7 +817,7 @@ export function runKeepAliveLoop() {
log.info('Pinging Appium server to keep session active');
try {
await driver.getTimeouts(); // Pings the Appium server to keep it alive
} catch (ign) {}
} catch {}
const now = Date.now();

// If the new command limit has been surpassed, prompt user if they want to keep session going
Expand Down Expand Up @@ -948,7 +948,7 @@ export function uploadGesturesFromFile(fileList) {

gesture.description = gesture.description || i18n.t('gestureImportedFrom', {fileName});
parsedGestures.push(_.omit(gesture, ['id']));
} catch (e) {
} catch {
invalidGestures[fileName] = [i18n.t('gestureInvalidJsonError')];
}
}
Expand Down
46 changes: 25 additions & 21 deletions app/common/renderer/actions/Session.js
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import {notification} from 'antd';
import {includes, isPlainObject, isUndefined, toPairs, union, values, without} from 'lodash';
import _ from 'lodash';
import moment from 'moment';
import {Web2Driver} from 'web2driver';

Expand Down Expand Up @@ -110,7 +110,7 @@ export function getCapsObject(caps) {
try {
let obj = JSON.parse(cap.value);
return {[cap.name]: obj};
} catch (ign) {}
} catch {}
}
return {[cap.name]: cap.value};
}),
Expand All @@ -134,7 +134,7 @@ export function showError(e, params = {methodName: null, secs: 5, url: null}) {
} else if (e.data) {
try {
e.data = JSON.parse(e.data);
} catch (ign) {}
} catch {}
if (e.data.value && e.data.value.message) {
errMessage = e.data.value.message;
} else {
Expand All @@ -149,8 +149,8 @@ export function showError(e, params = {methodName: null, secs: 5, url: null}) {
}
if (
errMessage === 'ECONNREFUSED' ||
includes(errMessage, 'Failed to fetch') ||
includes(errMessage, 'The requested resource could not be found')
_.includes(errMessage, 'Failed to fetch') ||
_.includes(errMessage, 'The requested resource could not be found')
) {
errMessage = i18n.t('couldNotConnect', {url});
}
Expand Down Expand Up @@ -265,7 +265,7 @@ export function newSession(caps, attachSessId = null) {
return false;
}
https = false;
if (!isPlainObject(desiredCapabilities[SAUCE_OPTIONS_CAP])) {
if (!_.isPlainObject(desiredCapabilities[SAUCE_OPTIONS_CAP])) {
desiredCapabilities[SAUCE_OPTIONS_CAP] = {};
}
if (!desiredCapabilities[SAUCE_OPTIONS_CAP].name) {
Expand All @@ -277,7 +277,7 @@ export function newSession(caps, attachSessId = null) {
let headspinUrl;
try {
headspinUrl = new URL(session.server.headspin.webDriverUrl);
} catch (ign) {
} catch {
showError(new Error(`${i18n.t('Invalid URL:')} ${session.server.headspin.webDriverUrl}`));
return false;
}
Expand Down Expand Up @@ -328,15 +328,19 @@ export function newSession(caps, attachSessId = null) {
desiredCapabilities['lt:options'].source = 'appiumdesktop';
desiredCapabilities['lt:options'].isRealMobile = true;
if (session.server.advanced.useProxy) {
desiredCapabilities['lt:options'].proxyUrl = isUndefined(session.server.advanced.proxy)
desiredCapabilities['lt:options'].proxyUrl = _.isUndefined(
session.server.advanced.proxy,
)
? ''
: session.server.advanced.proxy;
}
} else {
desiredCapabilities['lambdatest:source'] = 'appiumdesktop';
desiredCapabilities['lambdatest:isRealMobile'] = true;
if (session.server.advanced.useProxy) {
desiredCapabilities['lambdatest:proxyUrl'] = isUndefined(session.server.advanced.proxy)
desiredCapabilities['lambdatest:proxyUrl'] = _.isUndefined(
session.server.advanced.proxy,
)
? ''
: session.server.advanced.proxy;
}
Expand Down Expand Up @@ -422,7 +426,7 @@ export function newSession(caps, attachSessId = null) {
let experitestUrl;
try {
experitestUrl = new URL(session.server.experitest.url);
} catch (ign) {
} catch {
showError(new Error(`${i18n.t('Invalid URL:')} ${session.server.experitest.url}`));
return false;
}
Expand Down Expand Up @@ -464,7 +468,7 @@ export function newSession(caps, attachSessId = null) {
let mobitruUrl;
try {
mobitruUrl = new URL(webDriverUrl);
} catch (ign) {
} catch {
showError(new Error(`${i18n.t('Invalid URL:')} ${webDriverUrl}`));
return false;
}
Expand Down Expand Up @@ -524,13 +528,13 @@ export function newSession(caps, attachSessId = null) {
// If a newCommandTimeout wasn't provided, set it to 60 * 60 so that sessions don't close on users in short term.
// I saw sometimes infinit session timeout was not so good for cloud providers.
// So, let me define this value as NEW_COMMAND_TIMEOUT_SEC by default.
if (isUndefined(desiredCapabilities[CAPS_NEW_COMMAND])) {
if (_.isUndefined(desiredCapabilities[CAPS_NEW_COMMAND])) {
desiredCapabilities[CAPS_NEW_COMMAND] = NEW_COMMAND_TIMEOUT_SEC;
}

// If someone didn't specify connectHardwareKeyboard, set it to true by
// default
if (isUndefined(desiredCapabilities[CAPS_CONNECT_HARDWARE_KEYBOARD])) {
if (_.isUndefined(desiredCapabilities[CAPS_CONNECT_HARDWARE_KEYBOARD])) {
desiredCapabilities[CAPS_CONNECT_HARDWARE_KEYBOARD] = true;
}

Expand Down Expand Up @@ -602,7 +606,7 @@ export function newSession(caps, attachSessId = null) {
try {
mode = APP_MODE.WEB_HYBRID;
await driver.navigateTo('https://appium.io');
} catch (ign) {}
} catch {}
}

let mjpegScreenshotUrl =
Expand Down Expand Up @@ -836,7 +840,7 @@ export function setSavedServerParams() {
if (server) {
// if we have a cloud provider as a saved server, but for some reason the
// cloud provider is no longer in the list, revert server type to remote
if (values(SERVER_TYPES).includes(serverType) && !currentProviders.includes(serverType)) {
if (_.values(SERVER_TYPES).includes(serverType) && !currentProviders.includes(serverType)) {
serverType = SERVER_TYPES.REMOTE;
}
dispatch({type: SET_SERVER, server, serverType});
Expand Down Expand Up @@ -953,7 +957,7 @@ async function fetchAllSessions(baseUrl, authToken) {
try {
const res = await fetchSessionInformation({url, authToken});
return res.data.value ?? [];
} catch (err) {
} catch {
return [];
}
}
Expand All @@ -963,7 +967,7 @@ async function fetchAllSessions(baseUrl, authToken) {
try {
const res = await fetchSessionInformation({url, authToken});
return formatSeleniumGridSessions(res);
} catch (err) {
} catch {
return [];
}
}
Expand Down Expand Up @@ -1023,7 +1027,7 @@ export function saveRawDesiredCaps() {
}

// Translate the caps JSON to array format
let newCapsArray = toPairs(newCaps).map(([name, value]) => ({
let newCapsArray = _.toPairs(newCaps).map(([name, value]) => ({
type: (() => {
let type = typeof value;

Expand Down Expand Up @@ -1078,7 +1082,7 @@ export function stopAddCloudProvider() {
export function addVisibleProvider(provider) {
return async (dispatch, getState) => {
let currentProviders = getState().session.visibleProviders;
const providers = union(currentProviders, [provider]);
const providers = _.union(currentProviders, [provider]);
await setSetting(VISIBLE_PROVIDERS, providers);
dispatch({type: SET_PROVIDERS, providers});
};
Expand All @@ -1091,7 +1095,7 @@ export function removeVisibleProvider(provider) {
const action = changeServerType('remote');
await action(dispatch, getState);
}
const providers = without(visibleProviders, provider);
const providers = _.without(visibleProviders, provider);
await setSetting(VISIBLE_PROVIDERS, providers);
dispatch({type: SET_PROVIDERS, providers});
};
Expand Down Expand Up @@ -1172,7 +1176,7 @@ export function initFromQueryString(loadNewSession) {
try {
const state = JSON.parse(initialState);
dispatch({type: SET_STATE_FROM_URL, state});
} catch (e) {
} catch {
showError(new Error('Could not parse initial state from URL'), {secs: 0});
}
}
Expand Down
6 changes: 3 additions & 3 deletions app/common/renderer/components/Inspector/Inspector.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ import {
ThunderboltOutlined,
} from '@ant-design/icons';
import {Button, Card, Modal, Space, Spin, Switch, Tabs, Tooltip} from 'antd';
import {debounce} from 'lodash';
import _ from 'lodash';
import {useEffect, useRef, useState} from 'react';
import {useNavigate} from 'react-router';

Expand Down Expand Up @@ -123,7 +123,7 @@ const Inspector = (props) => {
setScaleRatio(windowSize.width / newImgWidth);
};

const updateScreenshotScaleDebounced = debounce(updateScreenshotScale, 50);
const updateScreenshotScaleDebounced = _.debounce(updateScreenshotScale, 50);

const checkMjpegStream = async () => {
const {setAwaitingMjpegStream} = props;
Expand All @@ -133,7 +133,7 @@ const Inspector = (props) => {
try {
await img.decode();
imgReady = true;
} catch (ign) {}
} catch {}
if (imgReady && isAwaitingMjpegStream) {
setAwaitingMjpegStream(false);
updateScreenshotScaleDebounced();
Expand Down
18 changes: 9 additions & 9 deletions app/common/renderer/lib/appium-client.js
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,7 @@ export default class AppiumClient {
if (methodName === 'quit') {
try {
await this.driver.quit();
} catch (ign) {}
} catch {}

_instance = null;

Expand Down Expand Up @@ -193,7 +193,7 @@ export default class AppiumClient {
let element = null;
try {
element = await this.driver.findElement(strategy, selector);
} catch (err) {
} catch {
return {};
}

Expand Down Expand Up @@ -301,13 +301,13 @@ export default class AppiumClient {
try {
const systemBars = await this.driver.executeScript('mobile:getSystemBars', []);
webviewTopOffset = systemBars.statusBar.height;
} catch (e) {
} catch {
try {
// to minimize the endpoint call which gets error in newer chromedriver.
const sessionDetails = await this.driver.getSession();
// in case driver does not support mobile:getSystemBars
webviewTopOffset = sessionDetails.viewportRect.top;
} catch (ign) {}
} catch {}
}
}
} else if (this.driver.client.isIOS) {
Expand All @@ -316,7 +316,7 @@ export default class AppiumClient {
// emulate optional chaining of deeply embedded property which might not exist using
// a try catch
browserName = this.driver.client.capabilities.browserName.toLowerCase();
} catch (ign) {}
} catch {}
const isSafari = browserName === 'safari';
if (isSafari) {
// on iOS, if we're in Safari simply find the top status bar and address bar and use its Y endpoint
Expand All @@ -336,12 +336,12 @@ export default class AppiumClient {
[],
);
webviewLeftOffset = deviceScreenInfo.statusBarSize.height;
} catch (e) {
} catch {
try {
const sessionDetails = await this.driver.getSession();
// in case driver does not support mobile:deviceScreenInfo
webviewLeftOffset = sessionDetails.statBarHeight;
} catch (ign) {}
} catch {}
}
}
} else {
Expand Down Expand Up @@ -406,7 +406,7 @@ export default class AppiumClient {
try {
await this.driver.getContexts();
return true;
} catch (ign) {}
} catch {}

// If the app under test returns non JSON format response
return false;
Expand Down Expand Up @@ -454,7 +454,7 @@ export default class AppiumClient {
let descriptionJSON = {attached: false};
try {
descriptionJSON = JSON.parse(page.description);
} catch (ign) {}
} catch {}

// You can have multiple `type` of pages, like service workers
// We need to have pages with or 1. an attached view or 2. with an empty description
Expand Down
2 changes: 1 addition & 1 deletion app/common/renderer/lib/client-frameworks/dotnet-nunit.js
Original file line number Diff line number Diff line change
Expand Up @@ -329,7 +329,7 @@ _driver.PerformActions(new List<ActionSequence> { swipe });
settings.push(`_driver.SetSetting("${settingName}", ${this.getCSharpVal(settingValue)});`);
}
return settings.join('\n');
} catch (e) {
} catch {
return `// Could not parse: ${settingsJson}`;
}
}
Expand Down
2 changes: 1 addition & 1 deletion app/common/renderer/lib/client-frameworks/java-common.js
Original file line number Diff line number Diff line change
Expand Up @@ -309,7 +309,7 @@ driver.perform(Arrays.asList(swipe));
settings.push(`driver.setSetting("${settingName}", ${this.getJavaVal(settingValue)});`);
}
return settings.join('\n');
} catch (e) {
} catch {
return `// Could not parse: ${settingsJson}`;
}
}
Expand Down
Loading

0 comments on commit adfb956

Please sign in to comment.