mardi 21 juillet 2020

How to open a browser in client side by Selenium Node js

I have a nodejs api action where I run a small selenium test.

When I run the test in my localmachine it works fine and I see browser new instance for testing.

In my local machine I can run by following way

https://localhost:3012/api/run_test

But in some reason (which I am trying to understand) in the server the browser instance is opening in the server and I don't see anything in client machine.

My goal is to open the browser in client side when I run my api from server (http://<mydomain.com>/api/run_test)

Here is my code

    const {Builder, By, Key, until} = require("selenium-webdriver");
    const chrome = require('selenium-webdriver/chrome');
    const chromeOptions = new chrome.Options();     

    chromeOptions.set("W3C", false);

    let driver = await new Builder().forBrowser('chrome').setChromeOptions(chromeOptions).build();
    
    await driver.get(testData.enviroment);
    await driver.findElement(By.id("qase-login-link")).click();

    var editName = driver.findElement(By.id("edit-name"));
    await editName.sendKeys(testData.l_username, Key.RETURN);

    var editPass = driver.findElement(By.id("edit-pass"));
    await editPass.sendKeys(testData.l_password, Key.RETURN);

So what to do to run the browser in client side.

Web: Nodejs with selenium webdirver Server: AWS ubuntu API: Express

thanks in advance

Aucun commentaire:

Enregistrer un commentaire