DEV Community

hjqueeen
hjqueeen

Posted on

Selenium Webdriver Javascript

1. Start the session

    driver = await new Builder().forBrowser('chrome').build();
Enter fullscreen mode Exit fullscreen mode

2. Take action on browser

    await driver.get('https://www.selenium.dev/selenium/web/web-form.html');
Enter fullscreen mode Exit fullscreen mode

3. Request browser information

    let title = await driver.getTitle();
Enter fullscreen mode Exit fullscreen mode

4. Establish(설립하다) Waiting Strategy

    await driver.manage().setTimeouts({implicit: 500});
Enter fullscreen mode Exit fullscreen mode

5. Find an element

    let textBox = await driver.findElement(By.name('my-text'));
    let submitButton = await driver.findElement(By.css('button'));
Enter fullscreen mode Exit fullscreen mode

6. Take action on element

    await textBox.sendKeys('Selenium');
    await submitButton.click();
Enter fullscreen mode Exit fullscreen mode

7. Request element information

    let value = await message.getText();
Enter fullscreen mode Exit fullscreen mode

8. End the session

    await driver.quit();
Enter fullscreen mode Exit fullscreen mode

EXAMPLE Github source code
NEXT learn about Assert module

Top comments (0)