question

NickK avatar image
NickK asked Philip.Joung commented

Downloading files through selenium

I have a dropdown menu in this format:

<div class="btn-group open">
								<button data-click-navigates-to="http://10.0.6.2:81/ui/admin/trust/certificate/68bfbf56-0b66-11e5-8316-800e8235b886/pem">Export</button>
								<button class="dropdown-toggle" data-toggle="dropdown" aria-expanded="false" data-original-title="" title="">
									<span class="caret"></span>
									<span class="sr-only">Toggle Dropdown</span>
								</button>
								<ul class="dropdown-menu" role="menu">
									<li><a href="http://10.0.6.2:81/ui/admin/trust/certificate/68bfbf56-0b66-11e5-8316-800e8235b886/pem">as PEM</a></li>
									<li><a href="http://10.0.6.2:81/ui/admin/trust/certificate/68bfbf56-0b66-11e5-8316-800e8235b886/der">as DER</a></li>
									
									<li class="divider"></li>
									<li><a href="http://10.0.6.2:81/ui/admin/trust/key/68bfcc12-0b66-11e5-9e94-8fff4c944e9d/public/pem">key as public PEM</a></li>
									<li><a href="http://10.0.6.2:81/ui/admin/trust/key/68bfcc12-0b66-11e5-9e94-8fff4c944e9d/public/der">key as public DER</a></li>
									<li><a href="http://10.0.6.2:81/ui/admin/trust/key/68bfcc12-0b66-11e5-9e94-8fff4c944e9d/private/pem">key as private PEM</a></li>
									<li><a href="http://10.0.6.2:81/ui/admin/trust/key/68bfcc12-0b66-11e5-9e94-8fff4c944e9d/private/der">key as private DER</a></li>
									
								</ul>
							</div>

The menu provides a means to download certificates in various formats.

I am able to locate each link using an xpath in the format:

//*[contains(text(), 'Bruce')]/..//a[contains(text(), 'as PEM')]

However, when I run the test, the certificate output is made into a URL which, of course, doesn't exist and the page returns a 404 error.

When I click on the dropdown option directly the certificate downloads as expected.

I would appreciate advice on how to emulate that result - clicking the button and having the file download as obviously my xpath is not doing what I expect it to and being honest, I don't understand why not.

Kind regards, and many thanks.

xpathdownloadsfilesdropdownjquery
10 |950

Up to 2 attachments (including images) can be used with a maximum of 512.0 KiB each and 1.0 MiB total.

NickK avatar image
NickK answered Philip.Joung commented

Hello, many thanks for your reply - we solved it by locating the object using an xpath, not downloading it and then copying the URL into another machine and running the test with wget from one to the other.

1 comment
10 |950

Up to 2 attachments (including images) can be used with a maximum of 512.0 KiB each and 1.0 MiB total.

drakesh avatar image drakesh commented ·

Thanks for the update Nick.

0 Likes 0 ·
Gerkman avatar image
Gerkman answered

Hi all,

I am also having trouble with download but in my case the problem is in the window that appears when I click the button to download some file. The window asks me if I want to save or open the file. But iTest does not recognize this window for saving or opening file. How can I solve this issue?

Also another problem is that if I set in the browser that this kind of file must always download without asking me, this setting is not stored in the browser.

I am using iTest 5.1.0 Build 77511.

My browser is Firefox version 31ESR

10 |950

Up to 2 attachments (including images) can be used with a maximum of 512.0 KiB each and 1.0 MiB total.

drakesh avatar image
drakesh answered

Could you please try to enable the option "Use web drive click" under Step Properties for click step (in a testcase) where you are trying to download the files. Attached is the screenshot for your reference. If it is not work, then try to check MIME-type of the content which you are trying to download. click.jpg


click.jpg (62.5 KiB)
10 |950

Up to 2 attachments (including images) can be used with a maximum of 512.0 KiB each and 1.0 MiB total.

Write an Answer

Hint: Notify or tag a user in this post by typing @username.

Up to 2 attachments (including images) can be used with a maximum of 512.0 KiB each and 1.0 MiB total.