can't find my element (selenium beginner)

George Xu

new programmer here- I am trying to make a cookieclicker bot using selenium. Cookie clicker is a website game linked below

http://orteil.dashnet.org/cookieclicker/

I am attempting to locate the element, like so

 WebElement element = driver.findElement(By.id("upgrades"));

and then I call it here:

upgrades = element.findElements(By.className("enabled"));

I want to make a list of "upgrades" that are "enabled". However, I get a null pointer exception on the second piece of code- but on the website there clearly is an element called "upgrades".

Thank you for your time!

edit:

this is the block of code from the game that I am trying to click

<div id="upgrades" class="storeSection upgradeBox"><div onclick="Game.UpgradesById[0].click(event);" class="crate upgrade enabled" onmouseout="Game.setOnCrate(0);Game.tooltip.shouldHide=1;" onmouseover="if (!Game.mouseDown) 

and I am trying to fish out these "enabled" upgrades

<div onclick="Game.UpgradesById[0].click(event);" class="crate upgrade enabled" onmouseout="Game.setOnCrate(0);Game.tooltip.shouldHide=1;" onmouseover="if (!Game.mouseDown) {Game.setOnCrate(this);Game.tooltip.dynamic=1;Game.tooltip.draw(this,function(){return Game.crate(Game.UpgradesById[0],'store',undefined,undefined,1)();},'store');Game.tooltip.wobble();}" id="upgrade0" style="background-position:0px 0px;"></div>

Shrini

I just checked on the website, your code requires modification.

Use the below code:

WebElement element = driver.findElement(By.id("upgrades"));
Actions acc=new Actions(driver);
acc.moveToElement(element).build().perform();
List<WebElement> upgrades = element.findElements(By.className("enabled"));

Let me know if this works for you.

Collected from the Internet

Please contact [email protected] to delete if infringement.

edited at
0

Comments

0 comments
Login to comment

Related

From Dev

Selenium can't find element

From Dev

Selenium IDE can't find an element

From Dev

Can't find an element Selenium Python

From Dev

Can't find element by id using selenium

From Dev

Can't find element selenium python

From Dev

Vim beginner: Can't find my source file after compilation and closing program

From Dev

Selenium WebDriver can't find element by link text

From Dev

Selenium WebDriver can't find element by @FindBy annotation

From Dev

Python Selenium: Can't find the login element of costar.com

From Dev

Can't print a browser.find_element_by_xpath with Selenium in python

From Dev

selenium python css selector can't find element

From Dev

Selenium / xpath - Can't find element, finding parent div

From Dev

Selenium can not find javascript element

From Dev

Selenium - driver.find_element_by_css_selector can't find the element (python)

From Dev

Selenium - driver.find_element_by_css_selector can't find the element (c#)

From Dev

Can't find the CSS element that disturb my layout

From Dev

Selenium can't locate this element

From Dev

Selenium / Python: Why isn't my Selenium find_element_by finding elements anymore after finding the first one in my for loop iterations?

From Dev

Can't get javascript working (beginner) - please check my code

From Dev

Beginner: Can't Order my WHERE Statements Properly with Subselect MIN?

From Dev

Can't get javascript working (beginner) - please check my code

From Dev

Selenium didn't find existing element

From Dev

Javascript: can't find element

From Dev

Can't find element in frame

From Dev

Can't find element in frame

From Dev

Can't find an element by "querySelector"

From Dev

Can't find elements of element

From Dev

I am trying to use selenium to load a waiting list and click the button, but I can't seem to find the element

From Dev

I am trying to use selenium to load a waiting list and click the button, but I can't seem to find the element

Related Related

  1. 1

    Selenium can't find element

  2. 2

    Selenium IDE can't find an element

  3. 3

    Can't find an element Selenium Python

  4. 4

    Can't find element by id using selenium

  5. 5

    Can't find element selenium python

  6. 6

    Vim beginner: Can't find my source file after compilation and closing program

  7. 7

    Selenium WebDriver can't find element by link text

  8. 8

    Selenium WebDriver can't find element by @FindBy annotation

  9. 9

    Python Selenium: Can't find the login element of costar.com

  10. 10

    Can't print a browser.find_element_by_xpath with Selenium in python

  11. 11

    selenium python css selector can't find element

  12. 12

    Selenium / xpath - Can't find element, finding parent div

  13. 13

    Selenium can not find javascript element

  14. 14

    Selenium - driver.find_element_by_css_selector can't find the element (python)

  15. 15

    Selenium - driver.find_element_by_css_selector can't find the element (c#)

  16. 16

    Can't find the CSS element that disturb my layout

  17. 17

    Selenium can't locate this element

  18. 18

    Selenium / Python: Why isn't my Selenium find_element_by finding elements anymore after finding the first one in my for loop iterations?

  19. 19

    Can't get javascript working (beginner) - please check my code

  20. 20

    Beginner: Can't Order my WHERE Statements Properly with Subselect MIN?

  21. 21

    Can't get javascript working (beginner) - please check my code

  22. 22

    Selenium didn't find existing element

  23. 23

    Javascript: can't find element

  24. 24

    Can't find element in frame

  25. 25

    Can't find element in frame

  26. 26

    Can't find an element by "querySelector"

  27. 27

    Can't find elements of element

  28. 28

    I am trying to use selenium to load a waiting list and click the button, but I can't seem to find the element

  29. 29

    I am trying to use selenium to load a waiting list and click the button, but I can't seem to find the element

HotTag

Archive