Skip to content

Commit b6542f9

Browse files
authored
Merge pull request #284 from Jongkeun/oneCommand
fixed error when migrating old test case which has exactly one command
2 parents c401c34 + c8b899b commit b6542f9

File tree

3 files changed

+29
-1
lines changed

3 files changed

+29
-1
lines changed

packages/selenium-ide/src/neo/IO/legacy/migrate.js

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -117,9 +117,11 @@ export function migrateTestCase(data) {
117117
const sanitized = sanitizeXml(data);
118118
const result = JSON.parse(convert.xml2json(sanitized, { compact: true }));
119119
const baseUrl = result.html.head.link._attributes.href;
120+
let tr = result.html.body.table.tbody.tr;
121+
tr = Array.isArray(tr) ? tr : [tr];
120122
const test = {
121123
name: result.html.body.table.thead.tr.td._text,
122-
commands: result.html.body.table.tbody.tr.filter(row => (row.td[0]._text && !/^wait/.test(row.td[0]._text))).map(row => (
124+
commands: tr.filter(row => (row.td[0]._text && !/^wait/.test(row.td[0]._text))).map(row => (
123125
{
124126
command: row.td[0]._text && row.td[0]._text.replace("AndWait", ""),
125127
target: xmlunescape(parseTarget(row.td[1])),
Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,21 @@
1+
<?xml version="1.0" encoding="UTF-8"?>
2+
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
3+
<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en" lang="en">
4+
<head profile="http://selenium-ide.openqa.org/profiles/test-case">
5+
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8" />
6+
<link rel="selenium.base" href="https://stage.local.com/" />
7+
<title>Log in as test user</title>
8+
</head>
9+
<body>
10+
<table cellpadding="1" cellspacing="1" border="1">
11+
<thead>
12+
<tr><td rowspan="1" colspan="3">A command</td></tr>
13+
</thead><tbody>
14+
<tr>
15+
<td>open</td>
16+
<td>/</td>
17+
<td></td>
18+
</tr>
19+
</tbody></table>
20+
</body>
21+
</html>

packages/selenium-ide/src/neo/__test__/IO/legacy/migrate.spec.js

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -74,6 +74,11 @@ describe("selenium test case migration", () => {
7474
const { test } = migrateTestCase(file);
7575
expect(test.commands.length).toBe(2);
7676
});
77+
it("should import a test case with a command in it", () => {
78+
const file = fs.readFileSync(path.join(__dirname, "IDE_test_10.html")).toString();
79+
const { test } = migrateTestCase(file);
80+
expect(test.commands.length).toBe(1);
81+
});
7782
});
7883

7984
describe("selenium suite migration", () => {

0 commit comments

Comments
 (0)