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

Not able to convert browser.actions() class #45

Open
SomeswararaoMarati opened this issue Aug 11, 2021 · 3 comments
Open

Not able to convert browser.actions() class #45

SomeswararaoMarati opened this issue Aug 11, 2021 · 3 comments
Labels
help wanted Extra attention is needed

Comments

@SomeswararaoMarati
Copy link

Hi,

Migrate Command is giving an error while converting the following.

await browser.actions().doubleClick(this.btnDoubleClick).perform();
await browser.actions().mouseDown(this.btnDoubleClick).mouseUp().perform();
await browser.actions().mouseMove(this.btnDoubleClick).click().perform();

ERR ./protractorTests/pages/buttons.page.js Transformation error (Error transforming ./protractorTests/pages/buttons.page.js:16)
Error transforming ./protractorTests/pages/buttons.page.js:16

    await browser.actions()
            ^

Can not transform "actions" command as it differs too much from the WebdriverIO implementation. We advise to refactor this code.

For more information on WebdriverIOs replacement command, see https://webdriver.io/docs/api/webdriver#performactions
at ./protractorTests/pages/buttons.page.js:16:14
All done.
Results:
1 errors
0 unmodified
0 skipped
0 ok

action commands from protractor are ot able to migrate

@christian-bromann
Copy link
Member

@SomeswararaoMarati as mentioned in the error message it is not feasible to transform these statements. They are too different in their syntax. Therefor unfortunately these lines have to be migrated manually.

@christian-bromann
Copy link
Member

I will keep this open in case someone wants to tackle this challenge. PRs welcome!

@christian-bromann christian-bromann added the help wanted Extra attention is needed label Aug 11, 2021
@noobzillla
Copy link

noobzillla commented Jan 25, 2023

There is a work around on this issue, by commenting out browser.actions() or Key, and migrate the script. if this a large file then you can create a file that will point where you need to comment out.

EX:

const fs = require("fs");

function commentOutBrowserActions(filePath){
    try {
        if (fs.existsSync(filePath)) {
            let file = fs.readFileSync(filePath, 'utf8');
            let lines = file.split("\n");

            for(let i = 1; i < lines.length; i++){
                if (lines[i].includes("browser.actions()") || lines[i].includes("Key.") || lines[i].includes('flow')) {
                    lines[i] = ">>>>>>> Fix Me" + lines[i];
                }
            }

            let commentedFile = lines.join("\n");
            fs.writeFileSync(filePath, commentedFile, 'utf8');
            console.log("Done");
        }
    } catch (error) {
        console.log(error);
    }
}

const filePath = process.argv[2];
commentOutBrowserActions(filePath);

You can run this file using node index.js file/path
After it is done executing it will be something like this

>>>>>>> Fix Me        browser.actions()

Hope this helps!!!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
help wanted Extra attention is needed
Projects
None yet
Development

No branches or pull requests

3 participants