最新消息:雨落星辰是一个专注网站SEO优化、网站SEO诊断、搜索引擎研究、网络营销推广、网站策划运营及站长类的自媒体原创博客

Selenium等待并使用nodejs单击

运维笔记admin11浏览0评论

Selenium等待并使用nodejs单击

Selenium等待并使用nodejs单击

我正在尝试登录FIFA终极团队...但是我不知道为什么我要尝试使用click操作没有任何作用...基本上我的网址是“登录”有什么主意吗?

require('chromedriver');
const webdriver = require('selenium-webdriver');

var until = webdriver.until;
var By = webdriver.By;

async function myMain(){

    let driver = new webdriver.Builder().forBrowser('chrome').build();
    await driver.get('/');
    await driver.wait(until.elementLocated(By.className('btn-standard call-to-action')), 15000);
    await driver.findElement(By.className('btn-standard call-to-action')).click();
}

myMain();
回答如下:

您的选择器可能不太正确。试试这个:

  await driver.wait(until.elementLocated(By.xpath("//button[text()='Login']")),15000);
  let loginButton = driver.findElement(By.xpath("//button[text()='Login']"));

  await driver.wait(until.elementIsEnabled(loginButton ,15000));

  await driver.findElement(By.xpath("//button[text()='Login']")).click();

与本文相关的文章

发布评论

评论列表(0)

  1. 暂无评论