我正在尝试使用Java,PhantomJS和GhostDriver截取一些推特页面的截图,但我一直在使用模态对话框(注册模式或cockies模态)获取截图。
Somene可以建议我如何找到这个关闭按钮并单击它吗?如图所示,按钮上没有类或ID:
这是html:
<body class="three-col logged-in user-style-Nike ms-windows enhanced-mini-profile ProfilePage ProfilePage--withBlockedWarning supports-drag-and-drop" dir="ltr" data-fouc-class-names="swift-loading" style="background-position: 0% 46px;">
<div id="kb-shortcuts-msg" class="visuallyhidden">
<script id="swift_loading_indicator" nonce="ZLwCWCggSYkG1TzZ4188og==">
<div id="doc" class="route-profile">
<div class="topbar js-topbar">
<div id="page-outer">
<div id="page-container" class="AppContent">
<div class="BannersContainer BannersContainer--overlay">
<div class="Banner eu-cookie-notice">
<style>
<div class="flex-module">
<div class="banner-row">
<span class="title">
To bring you Twitter, we and our partners use cookies on our and other websites. Cookies help personalize Twitter content, tailor Twitter Ads, measure their performance, and provide you with a better, faster, safer Twitter experience. By using our services, you agree to our
<a href="https://support.twitter.com/articles/20170514">Cookie Use</a>
.
</span>
<button type="button">
<span class="icon close-medium">
<span class="visuallyhidden">Close</span>
</span>
</button>
</div>
</div>
</div>
登录不是一种选择。
答案 0 :(得分:1)
每个DOM元素都可以添加一个点击处理程序。某些元素已经在其上自动添加了处理程序,例如表单内的<a>
元素或<button>
。
因此,您只需点击.eu-cookie-notice span.icon.close-medium
范围或其父.eu-cookie-notice .banner-row > button
。