Skip to content

Commit

Permalink
fixed script generation
Browse files Browse the repository at this point in the history
Signed-off-by: aryangupta701 <[email protected]>
  • Loading branch information
aryangupta701 committed Jun 26, 2023
1 parent 3dfd29e commit 4d3af84
Show file tree
Hide file tree
Showing 4 changed files with 14 additions and 3 deletions.
7 changes: 6 additions & 1 deletion source/types/zestScript/ZestStatement.ts
Original file line number Diff line number Diff line change
Expand Up @@ -117,10 +117,15 @@ class ZestStatementSwichToFrame extends ZestStatement {

frameName: string;

constructor(frameIndex: number, frameName = '') {
constructor(
frameIndex: number,
frameName = '',
windowHandle = 'windowHandle1'
) {
super('ZestClientSwitchToFrame');
this.frameIndex = frameIndex;
this.frameName = frameName;
this.windowHandle = windowHandle;
}

toJSON(): string {
Expand Down
2 changes: 1 addition & 1 deletion test/ContentScript/integrationTests.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -140,7 +140,7 @@ function integrationTests(
await page.close();
// Then
expect(JSON.stringify(Array.from(actualData))).toBe(
'["{\\"action\\":{\\"action\\":\\"reportZestScript\\"},\\"body\\":{\\"scriptJson\\":\\"{\\"frameIndex\\":0,\\"frameName\\":\\"frame1\\",\\"parent\\":false,\\"index\\":1,\\"enabled\\":true,\\"elementType\\":\\"ZestClientSwitchToFrame\\"}\\",\\"apikey\\":\\"not set\\"}}","{\\"action\\":{\\"action\\":\\"reportZestScript\\"},\\"body\\":{\\"scriptJson\\":\\"{\\"windowHandle\\":\\"windowHandle1\\",\\"type\\":\\"id\\",\\"element\\":\\"test-btn\\",\\"index\\":2,\\"enabled\\":true,\\"elementType\\":\\"ZestClientElementClick\\"}\\",\\"apikey\\":\\"not set\\"}}"]'
'["{\\"action\\":{\\"action\\":\\"reportZestScript\\"},\\"body\\":{\\"scriptJson\\":\\"{\\"windowHandle\\":\\"windowHandle1\\",\\"frameIndex\\":0,\\"frameName\\":\\"frame1\\",\\"parent\\":false,\\"index\\":1,\\"enabled\\":true,\\"elementType\\":\\"ZestClientSwitchToFrame\\"}\\",\\"apikey\\":\\"not set\\"}}","{\\"action\\":{\\"action\\":\\"reportZestScript\\"},\\"body\\":{\\"scriptJson\\":\\"{\\"windowHandle\\":\\"windowHandle1\\",\\"type\\":\\"id\\",\\"element\\":\\"test-btn\\",\\"index\\":2,\\"enabled\\":true,\\"elementType\\":\\"ZestClientElementClick\\"}\\",\\"apikey\\":\\"not set\\"}}"]'
);
});

Expand Down
2 changes: 1 addition & 1 deletion test/ContentScript/unitTests.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -336,7 +336,7 @@ test('should generate valid frame switch statement', () => {
);

expect(zestStatementSwichToFrame.toJSON()).toBe(
'{"frameIndex":0,"frameName":"testvalue","parent":false,"index":-1,"enabled":true,"elementType":"ZestClientSwitchToFrame"}'
'{"windowHandle":"windowHandle1","frameIndex":0,"frameName":"testvalue","parent":false,"index":-1,"enabled":true,"elementType":"ZestClientSwitchToFrame"}'
);
});

Expand Down
6 changes: 6 additions & 0 deletions test/ContentScript/webpages/testFrame.html
Original file line number Diff line number Diff line change
Expand Up @@ -5,5 +5,11 @@
</head>
<body>
<button id="test-btn">Test ME</button>
<script>
const button = document.getElementById('test-btn');
button.addEventListener('click', ()=>{
button.after("Clicked !!!");
})
</script>
</body>
</html>

0 comments on commit 4d3af84

Please sign in to comment.