I'm trying to take a screenshot of some twitter pages with Java, PhantomJS and GhostDriver, but all the time I'm getting screenshots with modal dialogs (sign-up modal or cockies modal).
Can somene suggest me how to find this close button and click it? There is no class or id directly on the button as you can see on the picture:
and here is the 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>
Signing in is not an option.
Every DOM element may have a click handler added to them. Some elements already have a handler automatically added on them, for example <a>
elements or <button>
inside of a form.
So, you can just click on the .eu-cookie-notice span.icon.close-medium
span or its parent .eu-cookie-notice .banner-row > button
.