Right click on element and selecting an option from the context menu

7.477 προβολές
Παράβλεψη και μετάβαση στο πρώτο μη αναγνωσμένο μήνυμα

Naresh

μη αναγνωσμένη,
13 Ιουν 2012, 11:44:03 π.μ.13/6/12
ως webd...@googlegroups.com
Hello all,

I have a requirement, I have to right click on element and selecting an option from the context menu.

I am able to perform right click. But I am not able to select any option.

As per my requirement, I have to save a rendered image onto disk.

For that I need to perform these actions

1). Right click on the element - Done
2). Select 'Save Image'
3). Save the image.

Can anybody advice me on this?

Thanks,
Naresh

Simon Stewart

μη αναγνωσμένη,
14 Ιουν 2012, 7:00:49 π.μ.14/6/12
ως webd...@googlegroups.com
This is about downloading content rather than interacting with a
JS-powered context menu. That's not explicitly supported by the
webdriver APIs.

Your best bet is to get the URL use "getAttribute" and then use some
other tool to grab the image.

Simon
> --
> You received this message because you are subscribed to the Google Groups
> "webdriver" group.
> To view this discussion on the web visit
> https://groups.google.com/d/msg/webdriver/-/jN6O7Z28UKgJ.
> To post to this group, send email to webd...@googlegroups.com.
> To unsubscribe from this group, send email to
> webdriver+...@googlegroups.com.
> For more options, visit this group at
> http://groups.google.com/group/webdriver?hl=en.

Naresh Thandu

μη αναγνωσμένη,
14 Ιουν 2012, 7:57:46 π.μ.14/6/12
ως webd...@googlegroups.com
Hello Simon,

Thanks for replying.

Following code is working fine for me with Firefox and IE. But it's not working with Chrome.

This is my code (C#).

IWebElement element = _driver.FindElement(By.Id("chart"));
            
var actions = new Actions(DriverBase.WebDriver.UnderlyingWebDriver);
ctions.Build();
            
var rClick = actions.ContextClick(element);
rClick.Perform();

Above code displaying menu which is a right click on image.

I have to choose 'Copy' menu option from that menu.

In firefox, I am able to get that by element.SendKeys(Keys.Control+"v") or calling element.SendKeys(Keys.ArrowDown) twice and element.SendKeys(Keys.Return) .For each arrow down, each item from the context menu is being selected.

On IE, calling element.SendKeys(Keys.ArrowDown) 13times and element.SendKeys(Keys.Return) is working.

But same kind of code is not working in Chrome. Can you please advice me on this.

Thanks,
Naresh
--
Regards,
Naresh Thandu,
+91-9916710222

Mark Collin

μη αναγνωσμένη,
14 Ιουν 2012, 11:36:02 π.μ.14/6/12
ως webd...@googlegroups.com

I have a file downloader class which also supports image download available here:

 

https://github.com/Ardesco/Ebselen/blob/master/ebselen-core/src/main/java/com/lazerycode/ebselen/customhandlers/FileDownloader.java

 

Short Link

 

I would however ask why you are performing this test.

 

If you are not checking the image (for example performing a SHA1/MD5 hash on it to ensure it is the image you expect) this test is completely pointless.  You would be better off getting the HTTP headers to see if the image exists (302/200 are the normal expected HTTP return codes). 

 

If you just want to see that right click has the expected options and that files can be downloaded you are not testing your website but the browser/OS.  If it doesn’t work could any of your devs fix it or will the problem be ignored.  If your devs can fix it can they force a new release of the browser/OS that contains the fix and can they force your users to download them (I’ll be very sureprised if you can answer yes to all of these questions).

--

Naresh

μη αναγνωσμένη,
14 Ιουν 2012, 11:57:27 π.μ.14/6/12
ως webd...@googlegroups.com
Hello Mark,

Thanks for your reply.

Even I didn't like my approach. But I couldn't find any other way. So I am copying the image using right click and saving the image.

Thanks for sharing your code.  But I am using C# to automate my tests. I am trying to convert your code to C#. 

I will update you after I am done with the conversion.

Thanks,
Naresh

To unsubscribe from this group, send email to webdriver+unsubscribe@googlegroups.com.

Naresh

μη αναγνωσμένη,
15 Ιουν 2012, 6:36:13 π.μ.15/6/12
ως webd...@googlegroups.com
Thanks Mark.

Your advice helped me. I was under wrong impression about accessing the image from website. 

I was not aware of adding the cookies to HTTP request, so I was not able to download the image. After looking at your post I understood how to add cookies to a http request.

Thanks once again.

-Naresh

Mark Collin

μη αναγνωσμένη,
15 Ιουν 2012, 6:50:08 π.μ.15/6/12
ως webd...@googlegroups.com
I would still question why you are downloading the image, do you actually do
anything with it once you have downloaded it?

If not you have just created a pointless test...
>> Link<https://github.com/Ardesco/Ebselen/blob/master/ebselen-core/src/
>> main/java/com/lazerycode/ebselen/customhandlers/FileDownloader.java>
>>
>>
>>
>> I would however ask why you are performing this test.
>>
>>
>>
>> If you are not checking the image (for example performing a SHA1/MD5
>> hash on it to ensure it is the image you expect) this test is
>> completely pointless. You would be better off getting the HTTP
>> headers to see if the image exists (302/200 are the normal expected HTTP
return codes).
>>
>>
>>
>> If you just want to see that right click has the expected options and
>> that files can be downloaded you are not testing your website but the
>> browser/OS. If it doesn't work could any of your devs fix it or will
>> the problem be ignored. If your devs can fix it can they force a new
>> release of the browser/OS that contains the fix and can they force
>> your users to download them (I'll be very sureprised if you can
>> answer yes to all of these questions).
>>
>>
>>
>>
>>
>> *From:* webd...@googlegroups.com
>> [mailto:webd...@googlegroups.com] *On Behalf Of *Naresh
>> *Sent:* 13 June 2012 16:44
>> *To:* webd...@googlegroups.com
>> *Subject:* [webdriver] Right click on element and selecting an option
>> from the context menu
>>
>>
>>
>> Hello all,
>>
>>
>>
>> I have a requirement, I have to right click on element and selecting
>> an option from the context menu.
>>
>>
>>
>> I am able to perform right click. But I am not able to select any
>> option=

Naresh

μη αναγνωσμένη,
15 Ιουν 2012, 6:59:00 π.μ.15/6/12
ως webd...@googlegroups.com
Here image is nothing but a Chart. Need to compare the charts.

So downloading the chart(image) and comparing with reference data.
>> [mailto:webdriver@googlegroups.com] *On Behalf Of *Naresh

Mike Riley

μη αναγνωσμένη,
21 Σεπ 2012, 1:01:30 μ.μ.21/9/12
ως webd...@googlegroups.com
You probably should have started a new thread for this, although it does match the subject here.

I haven't done this, but I believe that after you have it do the right click operation you can have it send the cursor keys and then an enter ("\n") to select something from the context menu.  I am sure I have seen that posted either in this forum or the selenium-users one.

Mike


On Friday, September 21, 2012 3:02:15 AM UTC-7, Srini wrote:

Hello all,

I have a requirement, I have to right click on element and need to select an option from the context menu. i am using JUnit frame work.

As per my requirement, I have to select View Details or Add to Bin or Manage option from right click context menu options.

Please find the attached screen. This is urgent for me.

Srini

μη αναγνωσμένη,
28 Σεπ 2012, 12:25:28 π.μ.28/9/12
ως webd...@googlegroups.com
Hi Naresh,

Can you please send me the webdriver right click script.


Thanks and Regards,
-Srinivas

somnath singh

μη αναγνωσμένη,
28 Σεπ 2012, 1:07:16 π.μ.28/9/12
ως webd...@googlegroups.com
you need to do this through Action Class .

       
  WebElement webelement = driver.findElement(By.xpath("Xpath Locator"));
        
        Actions actions = new Actions(driver);    
        Action action = actions.contextClick(webelement).build();
        action.perform();

--
You received this message because you are subscribed to the Google Groups "webdriver" group.
To view this discussion on the web visit https://groups.google.com/d/msg/webdriver/-/zeMrko755UQJ.

srini t

μη αναγνωσμένη,
28 Σεπ 2012, 1:49:56 π.μ.28/9/12
ως webd...@googlegroups.com
Hi,

I am getting some error. Please find the attached screen.

Thanks and Regards,
-Srinivas
--
Thanks & Regards
Srinivasa Rao T
+91-9949997347
Right Click Error.jpg

Manoj

μη αναγνωσμένη,
28 Σεπ 2012, 3:05:48 π.μ.28/9/12
ως webd...@googlegroups.com

bar...@adityasoftserv.com

μη αναγνωσμένη,
19 Οκτ 2017, 12:17:41 μ.μ.19/10/17
ως webdriver
Hello Naresh,
Could you please share the code how to do save an file by right clicking in C# if you have done.
Thanks in advance.

To unsubscribe from this group, send email to webdriver+...@googlegroups.com.

bar...@adityasoftserv.com

μη αναγνωσμένη,
19 Οκτ 2017, 12:17:58 μ.μ.19/10/17
ως webdriver
Απάντηση σε όλους
Απάντηση στον συντάκτη
Προώθηση
0 νέα μηνύματα