-
Notifications
You must be signed in to change notification settings - Fork 675
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat: debug with selector option added (#8066)
<!-- Thank you for your contribution. Before making a PR, please read our contributing guidelines at https://github.com/DevExpress/testcafe/blob/master/CONTRIBUTING.md#code-contribution We recommend creating a *draft* PR, so that you can mark it as 'ready for review' when you are done. --> ## Purpose The purpose of this PR is to allow passing selector to a t.debug call. Something like this t.debug(Selector). Then the selector will be shown in debug mode and highlighted. ## Approach So overall, the main goal was to pass the selector argument from server-side debug call to client-side selector-input-contaner. 1) src/test-run/index.ts Inside this file we have _internalExecuteCommand method. There is debug command type handling block. Inside of it we call _enqueueSetBreakpointCommand to which we pass command.selector as a second argument. This way we transfer Selector from debugCommand to breakpointCommand. 2) After the breakpointCommand is added to driverTaskQueue we can work with it on client-side. 3) On client-side we pass selector to _debugSelector method of SelectorInputContainer class. 4) In _debugSelector method we: - remove any previously highlighted elements, - get Selector name and assign it to this.value for SelectorInputContainer, - execute Selector to get elements for highlighting and indication, - highlight and indicate elements of the Selector ## References DevExpress/testcafe-private#163 ## Pre-Merge TODO - [x] Write tests for your proposed changes - [x] Make sure that existing tests do not fail
- Loading branch information
Showing
27 changed files
with
179 additions
and
102 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
2 changes: 1 addition & 1 deletion
2
src/client/driver/command-executors/action-executor/elements-retriever.ts
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,7 @@ | ||
import hammerhead from '../../deps/hammerhead'; | ||
|
||
const nativeMethods = hammerhead.nativeMethods; | ||
|
||
export function castArray (elements) { | ||
return nativeMethods.isArray(elements) ? elements : [elements]; | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,24 @@ | ||
import { CommandBase } from './base'; | ||
import TestRun from '../index'; | ||
|
||
declare class ExecuteClientFunctionCommandBase extends CommandBase { | ||
public constructor(obj: object, testRun: TestRun, type: string); | ||
public instantiationCallsiteName: string; | ||
public fnCode: string; | ||
public args: string[]; | ||
public dependencies: string[]; | ||
} | ||
|
||
export class ExecuteClientFunctionCommand extends ExecuteClientFunctionCommandBase { | ||
public constructor(obj: object, testRun: TestRun); | ||
} | ||
|
||
export class ExecuteSelectorCommand extends ExecuteClientFunctionCommandBase { | ||
public constructor(obj: object, testRun: TestRun); | ||
public visibilityCheck: boolean; | ||
public timeout?: number; | ||
public apiFnChain: string[]; | ||
public needError: boolean; | ||
public index: number; | ||
public strictError: boolean; | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,44 @@ | ||
import TYPE from './type'; | ||
import { ActionCommandBase } from './base'; | ||
|
||
export class ExecuteClientFunctionCommandBase extends ActionCommandBase { | ||
constructor (obj, testRun, type) { | ||
super(obj, testRun, type, false); | ||
} | ||
|
||
getAssignableProperties () { | ||
return [ | ||
{ name: 'instantiationCallsiteName', defaultValue: '' }, | ||
{ name: 'fnCode', defaultValue: '' }, | ||
{ name: 'args', defaultValue: [] }, | ||
{ name: 'dependencies', defaultValue: [] }, | ||
]; | ||
} | ||
} | ||
|
||
export class ExecuteClientFunctionCommand extends ExecuteClientFunctionCommandBase { | ||
static methodName = TYPE.executeClientFunction; | ||
|
||
constructor (obj, testRun) { | ||
super(obj, testRun, TYPE.executeClientFunction); | ||
} | ||
} | ||
|
||
export class ExecuteSelectorCommand extends ExecuteClientFunctionCommandBase { | ||
static methodName = TYPE.executeSelector; | ||
|
||
constructor (obj, testRun) { | ||
super(obj, testRun, TYPE.executeSelector); | ||
} | ||
|
||
getAssignableProperties () { | ||
return [ | ||
{ name: 'visibilityCheck', defaultValue: false }, | ||
{ name: 'timeout', defaultValue: null }, | ||
{ name: 'apiFnChain' }, | ||
{ name: 'needError' }, | ||
{ name: 'index', defaultValue: 0 }, | ||
{ name: 'strictError' }, | ||
]; | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,31 +1,13 @@ | ||
import { CommandBase, ActionCommandBase } from './base'; | ||
import { ActionCommandBase } from './base'; | ||
import { ExecuteClientFunctionCommand } from './execute-client-function'; | ||
import TestRun from '../index'; | ||
|
||
declare class ExecuteClientFunctionCommandBase extends CommandBase { | ||
public constructor(obj: object, testRun: TestRun, type: string); | ||
public instantiationCallsiteName: string; | ||
public fnCode: string; | ||
public args: string[]; | ||
public dependencies: string[]; | ||
} | ||
|
||
export class ExecuteClientFunctionCommand extends ExecuteClientFunctionCommandBase { | ||
public constructor(obj: object, testRun: TestRun); | ||
} | ||
|
||
export class ExecuteSelectorCommand extends ExecuteClientFunctionCommandBase { | ||
public constructor(obj: object, testRun: TestRun); | ||
public visibilityCheck: boolean; | ||
public timeout?: number; | ||
public apiFnChain: string[]; | ||
public needError: boolean; | ||
public index: number; | ||
public strictError: boolean; | ||
} | ||
|
||
export class WaitCommand extends ActionCommandBase { | ||
public constructor(obj: object, testRun: TestRun); | ||
public timeout: number; | ||
} | ||
|
||
export class DebugCommand extends ActionCommandBase { } | ||
export class DebugCommand extends ActionCommandBase { | ||
public constructor(obj: object, testRun: TestRun, validateProperties?: boolean); | ||
public selector?: ExecuteClientFunctionCommand; | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.