1

I m trying to find xpath of button:

<div data-testid="xray-export-csv" class="sc-dMfPxa dCFvBy"><svg width="24" height="24" fill="none" xmlns="http://www.w3.org/2000/svg" viewBox="0 0 24 24" class="sc-hXvPvl cOJGAW"><path d="M10.125 0h3.75C14.498 0 15 .502 15 1.125V9h4.11c.835 0 1.253 1.008.662 1.598l-7.13 7.135a.908.908 0 0 1-1.28 0l-7.139-7.135C3.633 10.008 4.05 9 4.884 9H9V1.125C9 .502 9.502 0 10.125 0ZM24 17.625v5.25c0 .623-.502 1.125-1.125 1.125H1.125A1.122 1.122 0 0 1 0 22.875v-5.25c0-.623.502-1.125 1.125-1.125h6.877l2.296 2.297a2.402 2.402 0 0 0 3.404 0l2.296-2.297h6.877c.623 0 1.125.502 1.125 1.125Zm-5.813 4.125a.94.94 0 0 0-.937-.938.94.94 0 0 0-.938.938.94.94 0 0 0 .938.938.94.94 0 0 0 .938-.938Zm3 0a.94.94 0 0 0-.937-.938.94.94 0 0 0-.938.938.94.94 0 0 0 .938.938.94.94 0 0 0 .938-.938Z"></path></svg></div>

Snapshot of the element:

I m trying to find xpath of button in picture that I attached.

undetected Selenium
  • 183,867
  • 41
  • 278
  • 352

1 Answers1

0

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

  • Using css_selector:

    element = driver.find_element(By.CSS_SELECTOR, "div[data-testid='xray-export-csv']")
    
  • Using xpath:

    element = driver.find_element(By.XPATH, "//div[@data-testid='xray-export-csv']")
    
undetected Selenium
  • 183,867
  • 41
  • 278
  • 352
  • I tried those methods but don't work. Inspect can't see the helium tab. – Ahmet Ozcelik Aug 03 '22 at 15:04
  • _ Inspect can't see the helium tab_: You have to change Selenium's [_focus_](https://stackoverflow.com/a/59521886/7429447) to the [adjascent tab](https://stackoverflow.com/questions/47082900/switching-into-new-window-using-selenium-after-button-click/47089023#47089023) through [Window Handling](https://stackoverflow.com/a/51893230/7429447) – undetected Selenium Aug 03 '22 at 15:09
  • But window handler can't define helium as a adjascent tab either. – Ahmet Ozcelik Aug 03 '22 at 17:18
  • _window handler can't define helium as a adjascent tab either_: Can you explain further why so? – undetected Selenium Aug 03 '22 at 18:05
  • helium is extension at at the chrome. It pops up in the same page when I click the Xray button that placed at the right center. So, window handler can't see because of it pops up in the same page. – Ahmet Ozcelik Aug 03 '22 at 18:47