-1

I need to save the image by right clicking using selenium and also by "Authenticating the browser with username and password". the link which i am sending through selenium looks like this "http://111.111.2.125/capture".

As I am new this concept, any suggestions will be highly helpful.

node mail
  • 1
  • 1
  • 2
  • Your question header is about `download image`where as description mentions about `Authenticating the browser with username and password`. Can you consider showcasing your work please? Thanks – undetected Selenium Jul 06 '17 at 06:28
  • @DebanjanB After loading my link there will be popup foe authentication , after authentication i need to download the image ? – node mail Jul 06 '17 at 06:52
  • For that you need to write some code. Did you try out anything? Can you consider showcasing your work please? Thanks – undetected Selenium Jul 06 '17 at 06:53

2 Answers2

0

For Right Click on Image you can use :

WebElement Image =driver.findElement(By.xpath("//img[@border='0']")); 
Actions action= new Actions(driver); 
action.contextClick(Image).build().perform();

Select "Save Image As" option

If you see In Image, We can select "Save Image As" option using CONTROL + V from keyboard. To do It In selenium webdriver, We will use bellow given code.

action.sendKeys(Keys.CONTROL, "v").build().perform();
sForSujit
  • 987
  • 1
  • 10
  • 24
0

Hope answer by @sForSujit has helped you for 'Right Clicking' on the image.

For Authenticating the browser with username and password, You could consider passing credentials in URL First, visit the URL with credentials then visit the URL without credentials

Example: First, access

http://username:password@111.111.2.125/capture

Then, access below one-

http://111.111.2.125/capture

Kapil
  • 397
  • 4
  • 6
  • Starting Chrome v-59, this has been disabled. Please see the detailed discussion [here](https://stackoverflow.com/questions/44443375/google-59-no-longer-supports-embedded-credentials/44767023#44767023). Actual Chromium announcement is [here](https://www.chromestatus.com/feature/5669008342777856). – demouser123 Jul 06 '17 at 18:17
  • @demouser123 - Thank you for updating me on this. – Kapil Jul 06 '17 at 18:26