我正在尝试显示一个error message on HTML page
。
错误消息是HTML / Javascript的组合,如下所示。
WebDriverException: Message: unknown error: Element
<div id="sidebar_item_Reports" style="height: 18px; white-space:nowrap;" onclick="
if (window.Event && Event.stopProp)
Event.stopProp(event);
" onmousedown="
if(Global.Central!=null) {
Global.Central.SelectItem('Reports',event);}
" class="sidebar_item sidebar_item_selected listItemSelected_fill skinGradient">...</div> is not clickable at point (105, 67). Other element would receive the click: <div class="overlay_concerto" style="position: absolute; height: 100%; width: 100%; left: 0px; top: 0px; z-index: 10;"></div>
(Session info: chrome=61.0.3163.100)
(Driver info: chromedriver=2.30.477700 (0057494ad8732195794a7b32078424f92a5fce41),platform=Windows NT 6.1.7601 SP1 x86_64)
正如我嵌入的一样,t被视为HTML对象。
<plaintext>
在最新的HTML版本上似乎不起作用。<pre> and <code>
也尝试过标签。
代码:
var = """WebDriverException: Message: unknown error: Element
<div id="sidebar_item_Reports" style="height: 18px; white-space:nowrap;" onclick="
if (window.Event && Event.stopProp)
Event.stopProp(event);
" onmousedown="
if(Global.Central!=null) {
Global.Central.SelectItem('Reports',event);}
" class="sidebar_item sidebar_item_selected listItemSelected_fill skinGradient">...</div> is not clickable at point (105, 67). Other element would receive the click: <div class="overlay_concerto" style="position: absolute; height: 100%; width: 100%; left: 0px; top: 0px; z-index: 10;"></div>
(Session info: chrome=61.0.3163.100)
(Driver info: chromedriver=2.30.477700 (0057494ad8732195794a7b32078424f92a5fce41),platform=Windows NT 6.1.7601 SP1 x86_64)"""
file_handler = open("test.html, "w")
file_handler.write("<!DOCTYPE html><html><head><body>"+var+"</body></head></html>")
HTML页面上的输出:
WebDriverException: Message: unknown error: Element
...
is not clickable at point (105, 67). Other element would receive the click: (Session info: chrome=61.0.3163.100) (Driver info: chromedriver=2.30.477700 (0057494ad8732195794a7b32078424f92a5fce41),platform=Windows NT 6.1.7601 SP1 x86_64)
这可能吗 ?任何人都可以在这里帮助我吗?
let st = `WebDriverException: Message: unknown error: Element <div id="sidebar_item_Reports" style="height: 18px; white-space:nowrap;" onclick="if (window.Event && Event.stopProp)Event.stopProp(event);" onmousedown="if(Global.Central!=null) {Global.Central.SelectItem('Reports',event);}" class="sidebar_item sidebar_item_selected listItemSelected_fill skinGradient">...</div> is not clickable at point (105, 67). Other element would receive the click: <div class="overlay_concerto" style="position: absolute; height: 100%; width: 100%; left: 0px; top: 0px; z-index: 10;"></div>(Session info: chrome=61.0.3163.100)(Driver info: chromedriver=2.30.477700 (0057494ad8732195794a7b32078424f92a5fce41),platform=Windows NT 6.1.7601 SP1 x86_64)`
let newStr = st.replace('<', '<');
let latest = newStr.replace('>', '>');
document.getElementById('d').innerHTML = latest;
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta http-equiv="X-UA-Compatible" content="IE=edge">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>Document</title>
</head>
<body>
<div id='d'>
</div>
</body>
</html>
解释:
在html中,如果我们想在页面内打印标签名称(与您的条件相同),我们需要将尖括号替换为<
(for <
)和>
(for >
)。
因此,在您的问题中,我们无法手动执行此操作,因为它是错误消息,而不是一些手写代码。所以我用javascript来relace<
与<
和>
用>
。
本文收集自互联网,转载请注明来源。
如有侵权,请联系[email protected] 删除。
我来说两句