0

Picture of the entry link/button

Here is the inspect result for the button that says +5 per day


    >span class="text user-links entry-method-title ng-scope ng-binding" ng-include="::'views/entry-text/'+entry_method.entry_type+'.html'">
    Click For a Daily Bonus Entry"
    
    </span>

<div class="entry-method bonus template" data-remove-popovers="" id="em6129519" ng-class="{expanded: entryState.expanded == entry_method, template: entry_method.template, 'completed-entry-method': !canEnter(entry_method) &amp;&amp; isEntered(entry_method)}" ng-repeat="entry_method in ::entry_methods">

here is the HTML given information when I inspect the link/button, I have tried to use XPath, CSS, link text, and class name and it keeps giving me an error saying it cannot identify the element. Does anyone have a suggestion for how to identify this, it is on gleam.io for a giveaway I'm trying to automate this so i don't have to log in and press this everyday. This is my first ever web interfacing project with python.

Here is my most recent try

driver.maximize_window()
time.sleep(10)

driver.execute_script("window.scrollTo(0, 1440)")

time.sleep(10)

button2 = driver.find_element_by_class_name("text user-links entry-method-title ng-scope ng-binding")
button2.click()

2 Answers2

0

Similar to a previous issue, Selenium find_element_by_class_name and find_element_by_css_selector not working, you can't have spaces in your class name when using driver.find_element_by_class_name. Instead, find the element via css_selector and replace each space with a dot.

driver.find_element_by_css_selector("span.text.user-links.entry-method-title.ng-scope.ng-binding")

That'll fix what you have above, but keep in mind there are other ways to make selenium actions more reliable (eg. WebDriverWait, etc). And there may be a cleaner selector to use than the one above.

Michael Mintz
  • 9,007
  • 6
  • 31
  • 48
0

I believe the element you want to access is contained within an "iframe", thus you must first switch to iframe before you can access it using selectors.

driver.switch_to.frame(x.find_element_by_xpath("PUT IFRAME XPATH HERE"))
Andreas Violaris
  • 2,465
  • 5
  • 13
  • 26