1

I am trying to write code to check download is completed by selenium and chrome driver. My idea is

1.Go to download page("chrome://downloads/")

2.Check the url to ensure we have downloaded file from that site (locate http://xxxxxxxx)

3.Check download status( If I found "show in folder", it implies download success. if not, download failed)

I am stucking in step2, when I try to locate the url. I used developer tools, move cursor to the url to locate the element,and then I right click and copy the xpath. The xpath is like this

          //*[@id="file-link"]

And then I try to click ctrl+F in developer tool and paste the xpath again. I cannot locate the element. Why? Checked there is no frame.

  • Does this answer your question? [Accessing Shadow DOM tree with Selenium](https://stackoverflow.com/questions/23920167/accessing-shadow-dom-tree-with-selenium) – Ramon Medeiros Jan 08 '20 at 15:12

2 Answers2

0

It shadow DOM and need to select /deep/ using CSS selector

downloads-manager/deep/downloads-item/deep/a[id="file-link"]
ewwink
  • 17,132
  • 2
  • 41
  • 54
0

Another way of doing this could be writing a small Java utility for the same using File Class. Something like this:

 File f = new File("C:\\Users\\username\\Downloads\\Users_" + fielName+ ".xls");
    Assert.assertTrue(f.exists());
Neha
  • 316
  • 1
  • 4
  • 14