tag:blogger.com,1999:blog-4756555425544853006.post5040843954626410289..comments2024-03-29T14:02:49.069+05:30Comments on QA Automation: Capturing Screenshot in Headless ModeAnkur Jainhttp://www.blogger.com/profile/00534956632099381866noreply@blogger.comBlogger3125tag:blogger.com,1999:blog-4756555425544853006.post-81887729543335982302021-04-09T01:47:08.271+05:302021-04-09T01:47:08.271+05:30Hi, I am running my code on Jenkins- Linux system ...Hi, I am running my code on Jenkins- Linux system in headless mode. To make browser compatible below is the code i am using:<br />Open Browser in headless mode:<br /> public boolean openBrowser(String object, String data) throws Exception {<br /> try {<br /> String oSName = System.getProperty("os.name");<br /><br /><br /> if (data.equals("Chrome")) {<br /> if (oSName.toUpperCase().contains("WIN")) {<br /> System.setProperty("webdriver.chrome.driver", System.getProperty("user.dir") + "/Drivers/windows/chromedriver.exe");<br /> //System.setProperty("webdriver.chrome.driver", "Drivers/chromedriver.exe");<br /> Constants.driver = new ChromeDriver();<br /> Constants.driver.manage().window().maximize();<br /> } else {<br /> System.setProperty("webdriver.chrome.driver", System.getProperty("user.dir") + "/Drivers/linux/chromedriver");<br /> ChromeOptions options = new ChromeOptions();<br /> options.setHeadless(true);<br /> options.addArguments("--window-size=1920,1080");<br /> options.addArguments("--disable-gpu");<br /> options.addArguments("--disable-extensions");<br /> options.setExperimentalOption("useAutomationExtension", false);<br /> options.addArguments("--proxy-server='direct://'");<br /> options.addArguments("--proxy-bypass-list=*");<br /> options.addArguments("--start-maximized");<br /> options.addArguments("--headless");<br /> options.addArguments("--whitelisted-ips");<br /> options.addArguments("--disable-dev-shm-usage");<br /> options.addArguments("--no-sandbox");<br /> Constants.driver = new ChromeDriver(options); <br /> Constants.driver.manage().window().maximize();<br /> //options.addArguments("--no-sandbox");<br /> }<br /><br />Capture snapshot code i am using is:<br />public static void takeSnapShot() throws Exception {<br /><br /> SimpleDateFormat format = new SimpleDateFormat("yyyy-MM-dd-hh-mm-ss");<br /> String dateString = format.format(new Date());<br /> String vScenarioN = BaseStep.scenarioName;<br /><br /> //Convert web driver object to TakeScreenshot<br /><br /> //String fileWithPath = System.getProperty("user.dir") + "\\Screenshot\\SS"+"_"+vScenarioN+ "_"+ dateString + ".png";<br /> String fileWithPath = System.getProperty("user.dir") + "\\Screenshot\\SC" + "_" + vScenarioN + "_" + dateString + ".png";<br /><br /> ;<br /> //String fileWithPath = "C://Framework//CucumberSeleniumProject//CucumberSeleniumProject////SC" + dateString + ".png";<br /> TakesScreenshot scrShot = ((TakesScreenshot) Constants.driver);<br /> //Call getScreenshotAs method to create image file<br /> File SrcFile = scrShot.getScreenshotAs(OutputType.FILE);<br /> //Move image file to new destination<br /> File DestFile = new File(fileWithPath);<br /> //Copy file at destination<br /> FileUtils.copyFile(SrcFile, DestFile);<br /> Reporter.addScreenCaptureFromPath(fileWithPath);<br /> }<br /><br />Still i am unable to see those files on Jenkins workspace<br />Can you help..!Anonymoushttps://www.blogger.com/profile/08205324040222911819noreply@blogger.comtag:blogger.com,1999:blog-4756555425544853006.post-79294260356187856412019-06-15T20:22:39.024+05:302019-06-15T20:22:39.024+05:30Hi Vaibhav Please share the screenshot of page and...Hi Vaibhav Please share the screenshot of page and the issue you are getting .i will look and based on that i can suggest some solution.My email id ankur.jain.cs@gmail.comAnkur Jainhttps://www.blogger.com/profile/00534956632099381866noreply@blogger.comtag:blogger.com,1999:blog-4756555425544853006.post-31506333237492560672019-06-14T00:23:23.493+05:302019-06-14T00:23:23.493+05:30Hi Ankur,
Hope you doing well.
I am working as As...Hi Ankur,<br />Hope you doing well.<br /><br />I am working as Associate Software Engineer.<br />I am trying to take screenshot of full page but sticky header in the website creating problem.<br />How can I correct it.?<br />Please help me out.<br /><br />Thanks,<br />VaibhavAnonymoushttps://www.blogger.com/profile/03770989243642912176noreply@blogger.com