I tried the whole day to press a button in a Automated test using a different selectors (id, class and href) but I could't. With ID is more easier, but I practice with youtube and after the first click (on the hamburguer menu) I could't press on any tab after that (History, Subscriptions, Library, etc..)
const { Given, When, Then } = require('cucumber');
const { Builder, By, Key, until } = require('selenium-webdriver');
const { expect, assert } = require('chai');
let driver = new Builder().forBrowser('chrome').build();
Given('Youtube', {timeout: 2 * 5000}, async function () {
await driver.get('https://www.youtube.com/?gl=ES&hl=es');
});
When('Library', {timeout: 2 * 5000}, async function () {
await driver.findElement(By.id("guide-icon")).click();
});
When('Notice', {timeout: 2 * 5000}, async function () {
await driver.findElement(By.css("style-scope ytd-guide-entry-renderer")).click();
});
Also tried with Xpath (I need to locate specific parts of the web, and I have multiple classes with same values).
When('Notice', {timeout: 2 * 5000}, async function () {
await driver.findElement(By.xpath("//a[@href='/feed/history']")).click();
});
The feature file is OK.
I Receive this message everytime when I run the test
NoSuchElementError: no such element: Unable to locate element: {"method":"css selector","selector":"style-scope ytd-guide-entry-renderer"}
(Session info: chrome=80.0.3987.132)
Thank you guys ;)
Aucun commentaire:
Enregistrer un commentaire