Я не могу нажать на две ссылки в Selenium Javascript - PullRequest
0 голосов
/ 13 апреля 2020

Я пытаюсь go перейти на одну страницу, щелкнуть ссылку, а затем перейти на другую. Однако после нажатия на первую ссылку я получаю сообщение об ошибке. Я проверил css локаторы, и оба они правы.

const { Builder, By, Key, until} = require("selenium-webdriver");

const driver = new Builder().forBrowser("firefox").build();

driver.get("http://facebook.com");
driver.findElement(By.css(".pageFooterLinkList > li:nth-child(10) > a:nth-child(1)")).click();
driver.wait(until.elementLocated(By.css('td.login_form_label_field:nth-child(2) > div:nth-child(1) > a:nth-child(1)')), 5000);
driver.findElement(By.css("td.login_form_label_field:nth-child(2) > div:nth-child(1) > a:nth-child(1)")).click();

Ошибка

(node:8968) UnhandledPromiseRejectionWarning: StaleElementReferenceError: The element reference 
of <a href="https://www.facebook.com/recover/initiate?lwv=110&ars=royal_blue_bar"> is stale; either the element is no longer attached to the DOM, it is not in the current frame context, or the document has been refreshed
    at Object.throwDecodedError (C:\Project1\node_modules\selenium-webdriver\lib\error.js:550:15)
    at parseHttpResponse (C:\Project1\node_modules\selenium-webdriver\lib\http.js:565:13)       
    at Executor.execute (C:\Project1\node_modules\selenium-webdriver\lib\http.js:491:26)        
    at processTicksAndRejections (internal/process/task_queues.js:97:5)
    at async thenableWebDriverProxy.execute (C:\Project1\node_modules\selenium-webdriver\lib\webdriver.js:700:17)
(node:8968) UnhandledPromiseRejectionWarning: Unhandled promise rejection. This error originated either by throwing inside of an async function without a catch block, or by rejecting a promise which was not handled with .catch(). To terminate the node process on unhandled promise rejection, use the CLI flag `--unhandled-rejections=strict` (see https://nodejs.org/api/cli.html#cli_unhandled_rejections_mode). (rejection id: 1)
(node:8968) [DEP0018] DeprecationWarning: Unhandled promise rejections are deprecated. In the future, promise rejections that are not handled will terminate the Node.js process with a non-zero exit code.

Спасибо за помощь.

Добро пожаловать на сайт PullRequest, где вы можете задавать вопросы и получать ответы от других членов сообщества.
...