Skip to content

Instantly share code, notes, and snippets.

Show Gist options
  • Save Kaperskyguru/5b1e5c8bd4e0da15947492ca217986eb to your computer and use it in GitHub Desktop.
Save Kaperskyguru/5b1e5c8bd4e0da15947492ca217986eb to your computer and use it in GitHub Desktop.
const { Builder, By, ChromiumWebDriver } = require("selenium-webdriver");
const chrome = require("selenium-webdriver/chrome");
async function DynamicTableLocallyExample() {
// launch the browser
let driver = await new Builder().forBrowser("chrome").build();
// Navigate to our app application
await driver.get("");
// Example One
const innerText1 = await driver
// Example Two
const innerText2 = await driver
// Example Three
const innerText3 = await driver
.findElement(By.xpath("//table[@background = \"grey\"]/tbody/tr[2]/td[1]"))
//clean the browser
async function DynamicTableWithLambdaTest() {
const USERNAME = ""; //replace with your username
const KEY = ""; //replace with your accesskey
const GRID_HOST = "";
const capabilities = {
browserName: "Chrome",
browserVersion: "107.0",
"LT:Options": {
username: USERNAME,
accessKey: KEY,
geoLocation: "US",
platformName: "Windows 10",
build: "Date Picker",
project: "Date Picker Example",
w3c: true,
plugin: "node_js-node_js",
const gridUrl = "https://" + USERNAME + ":" + KEY + "@" + GRID_HOST;
let driver
try {
driver = await new Builder()
return await selectDynamicTable(driver);
} catch (error) {
throw error;
} finally {
await driver.quit();
async function selectDynamicTable(driver) {
//Launch the browser
if(!driver) return
await driver.get("")
//Finding the number of Rows
const numberOfRows = await driver.findElements(By.xpath('//*[@id="example"]/tbody/tr[1]/td[1]'));
const totalRows= numberOfRows.length;
console.log("No of rows in this table : " + totalRows);
//Finding the number of Columns
const numberOfColumns = await driver.findElements(By.xpath("//*[@id="example"]/thead/tr/th[1]"));
const totalColumns= numberOfColumns.length;
console.log("No of columns in this table : " + totalColumns);
//Finding cell value at 7th row and 1st column
const innerText = await driver
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment