这个HTML代码
"use strict";
var webdriver = require('selenium-webdriver');
var proxy = require('selenium-webdriver/proxy');
var browser = new webdriver.Builder().usingServer()
.withCapabilities({'browserName': 'chrome'}).build();
browser.get("http:/ит.логер.рф/заказать");
browser.wait(function() {
return browser.getTitle().then(function(title) {
return 'Студия Логер' === title;
});
}, 2000);
//browser.findElement(webdriver.By.css('.wcm_head_close_wrap')).click();
browser.wait(function() {
return browser.findElement(webdriver.By.css(".wcm_head_close")).click().then(function() {
return "OK!";
});
}, 8000);
此javascript代码
Array.prototype.forEach.call(document.body.querySelectorAll("*[data-mask]"), applyDataMask);
function applyDataMask(field) {
var mask = field.dataset.mask.split('');
// For now, this just strips everything that's not a number
function stripMask(maskedData) {
function isDigit(char) {
return /\d/.test(char);
}
return maskedData.split('').filter(isDigit);
}
// Replace `_` characters with characters from `data`
function applyMask(data) {
return mask.map(function(char) {
if (char != '_') return char;
if (data.length == 0) return char;
return data.shift();
}).join('')
}
function reapplyMask(data) {
return applyMask(stripMask(data));
}
function changed() {
var oldStart = field.selectionStart;
var oldEnd = field.selectionEnd;
field.value = reapplyMask(field.value);
field.selectionStart = oldStart;
field.selectionEnd = oldEnd;
}
field.addEventListener('click', changed)
field.addEventListener('keyup', changed)
}
错误: NoSuchElementError:没有这样的元素:无法找到元素:{"方法":" css选择器","选择器":" .wcm_head_close"}
答案 0 :(得分:0)
试试这个:
By.class( “wcm_head_close”);
在java中它的工作原理如下: driver.findElement(By.className( “abcClass”))上单击();