1

I'm trying to use Rselenium+seleniumPipes to access this zipfile by name: "PUB004_PRE_20220316.zip"

<tr id="l1_VkFMX1BSRV9SUl8yMDIyMDMxMi56aXA" class="elfinder-cwd-file elfinder-ro ui-selectee ui-draggable-handle" title="PUB004_PRE_20220316.zip
Hoy 02:20 PM (4.22 MB)">
  <td class="elfinder-col-name">
   <div class="elfinder-cwd-file-wrapper">
     <span class="elfinder-cwd-icon elfinder-cwd-icon-application elfinder-cwd-icon-zip">.</span>
     <span class="elfinder-perms"></span>
     <span class="elfinder-lock"></span>
     <span class="elfinder-cwd-filename">PUB004_PRE_20220316.zip</span>
   </div>
 </td>
 <td class="elfinder-col-perm">lectura</td>
 <td class="elfinder-col-date">Hoy 02:20 PM</td>
 <td class="elfinder-col-size">4.22 MB</td>
 <td class="elfinder-col-kind">Archivo ZIP</td>
</tr>

Picture of the whole code

But cant seem to get the xpath correctly.

Some of my tries:

select_file <- robot$findElement(
  "xpath", "//tr[.//td[.//div[@class='elfinder-cwd-file-wrapper']]]//span[@class='elfinder-cwd-filename']//*[text()='PUB004-PRE-20220316.zip']")
select_file$clickElement()

select_file <- robot$findElement(
  "xpath", "//*[@class='elfinder-cwd-file-wrapper']//*[@class='elfinder-cwd-filename']//*[text()='PUB004-PRE-20220316.zip']")
select_file$clickElement()

select_file <- robot$findElement(
  "xpath", "//*[@class='elfinder-cwd-filename']//*[text()='PUB004-PRE-20220316.zip']")
select_file$clickElement()

This is the webpage. I want to download a the zip files.

Note: I need to do it by name because I'm interested in downloading the file programmatically by date (20220316).

2 Answers2

0

If I understand you correctly, you want to click on tr parent element containing the span element containing the desired file name in it's text. Right?
But the tr element itself contains that string in it's title.
So, why not simply to use this XPath: ?

"//tr[contains(@title,'20220316')]"
Prophet
  • 32,350
  • 22
  • 54
  • 79
  • This looks promising, when I run it, I doesnt give and error, looks like it does find the element, the problem is that the `clickElement()` doesnt seem to actually click something in the page. I added the webpage url in my post it that helps – Andrea Vargas Mar 16 '22 at 21:17
0

Seems you were close enough, instead of _ character it should have been - character and should have been PUB004-PRE-20220316.zip


Solution

To identify the element you can use either of the following locator strategies:

  • Using xpath and the innerText:

    select_file <- robot$findElement("xpath", "//span[text()='PUB004-PRE-20220316.zip']")
    
  • Using xpath with class and the innerText:

    select_file <- robot$findElement("xpath", "//span[@class='elfinder-cwd-filename' and text()='PUB004-PRE-20220316.zip']")
    
undetected Selenium
  • 183,867
  • 41
  • 278
  • 352
  • Thank you for your response! Unfortunately, both of these return: `Error: Summary: NoSuchElement Detail: An element could not be located on the page using the given search parameters. class: org.openqa.selenium.NoSuchElementException Further Details: run errorDetails method`. I added the webpage url in my post it that helps – Andrea Vargas Mar 16 '22 at 21:15
  • Checkout the updated answer and let me know the status. – undetected Selenium Mar 16 '22 at 21:17