Last active
December 3, 2022 09:05
-
-
Save solanoize/807ce0349a1dc0becc659f3ec8649dd3 to your computer and use it in GitHub Desktop.
Source untuk menghindari ads
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| package com.asuransijiwa.assurance; | |
| import java.time.Duration; | |
| import org.openqa.selenium.By; | |
| import org.openqa.selenium.WebDriver; | |
| import org.openqa.selenium.WebElement; | |
| import org.openqa.selenium.chrome.ChromeDriver; | |
| import org.openqa.selenium.support.ui.WebDriverWait; | |
| import pages.RegisterPage; | |
| public class RemoveAds { | |
| public static void main(String[] args) throws InterruptedException { | |
| System.setProperty("webdriver.chrome.driver", "C:\\webdrivers\\chromedriver.exe"); | |
| WebDriver driver = new ChromeDriver(); | |
| driver.get("https://demo.guru99.com/V4/index.php"); | |
| WebDriverWait wait = new WebDriverWait(driver, Duration.ofSeconds(40)); | |
| driver.findElement(By.xpath("//a[normalize-space()='Bank Project']")).click(); | |
| driver.findElement(By.xpath("//a[normalize-space()='Bank Project V1']")).click(); | |
| WebElement frame1 = driver.findElement(By.id("google_ads_iframe_/24132379/INTERSTITIAL_DemoGuru99_0")); | |
| driver.switchTo().frame(frame1); | |
| WebElement frame2 = driver.findElement(By.id("ad_iframe")); | |
| driver.switchTo().frame(frame2); | |
| driver.findElement(By.xpath("//div[@id='dismiss-button']/div")).click(); | |
| driver.switchTo().defaultContent(); | |
| Thread.sleep(5000); | |
| driver.close(); | |
| } | |
| } |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| package com.asuransijiwa.assurance; | |
| import java.io.File; | |
| import java.io.IOException; | |
| import java.time.Duration; | |
| import org.apache.commons.io.FileUtils; | |
| import org.openqa.selenium.By; | |
| import org.openqa.selenium.OutputType; | |
| import org.openqa.selenium.TakesScreenshot; | |
| import org.openqa.selenium.WebDriver; | |
| import org.openqa.selenium.WebElement; | |
| import org.openqa.selenium.chrome.ChromeDriver; | |
| import org.openqa.selenium.support.ui.WebDriverWait; | |
| import pages.RegisterPage; | |
| public class RemoveAds { | |
| // Method screenshot bikin dulu | |
| public static void ambilGambar(WebDriver driver, String simpanGambar) throws IOException { | |
| TakesScreenshot screenShot = ((TakesScreenshot) driver); | |
| File srcFile = screenShot.getScreenshotAs(OutputType.FILE); | |
| File tempatSimpanFile = new File(simpanGambar); | |
| // Simpan gambar | |
| FileUtils.copyFile(srcFile, tempatSimpanFile); | |
| } | |
| public static void main(String[] args) throws InterruptedException, IOException { | |
| System.setProperty("webdriver.chrome.driver", "C:\\webdrivers\\chromedriver.exe"); | |
| WebDriver driver = new ChromeDriver(); | |
| driver.get("https://demo.guru99.com/V4/index.php"); | |
| WebDriverWait wait = new WebDriverWait(driver, Duration.ofSeconds(40)); | |
| driver.findElement(By.xpath("//a[normalize-space()='Bank Project']")).click(); | |
| driver.findElement(By.xpath("//a[normalize-space()='Bank Project V1']")).click(); | |
| // Cara pakai screenshot. | |
| RemoveAds.ambilGambar(driver, "contoh-ss.png"); | |
| WebElement frame1 = driver.findElement(By.id("google_ads_iframe_/24132379/INTERSTITIAL_DemoGuru99_0")); | |
| driver.switchTo().frame(frame1); | |
| WebElement frame2 = driver.findElement(By.id("ad_iframe")); | |
| driver.switchTo().frame(frame2); | |
| driver.findElement(By.xpath("//div[@id='dismiss-button']/div")).click(); | |
| driver.switchTo().defaultContent(); | |
| Thread.sleep(5000); | |
| driver.close(); | |
| } | |
| } |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment