0

I recently started doing botting to try and get my hands on a better graphics card. My issue is this button: button html which has no name or anything useful that would allow my bot to detect it. I have tried using its XPath but to no success. my XPath attempt (I used the real XPath don't worry). Any help would be much appreciated :)

2 Answers2

0
driver.execute_script('return document.querySelector("core-button").shadowRoot.querySelector("a")').click()

use execute_script and then return the element inside the shadowRoot

PDHide
  • 18,113
  • 2
  • 31
  • 46
0

I used the following code to fix my issue.

browser = webdriver.Chrome()
def expand_shadow_element(element):
shadow_root = browser.execute_script('return arguments[0].shadowRoot', element)
return shadow_root

root1 = browser.find_element_by_tag_name('app-shell')
shadow_root1 = expand_shadow_element(root1)
    
root2 = shadow_root1.find_element_by_css_selector('request-page')
shadow_root2 = expand_shadow_element(root2)

root3 = shadow_root2.find_element_by_css_selector('box-content')
shadow_root3 = expand_shadow_element(root3)

pay_button = shadow_root3.find_element_by_css_selector("core-button")
pay_button.click()