3

I am trying to use the python selenium web-driver to locate the tile/button elements for googles minesweeper game, but they do not appear as individual HTML elements that can be referenced when inspected. I can reference the element containing the tiles to click any tile with selenium methods, but I have no way of accessing the state of each tile with python, as the element.text method returns None when called on the larger element. Is there any way to access the state of the tiles without screenshotting/text image recognition?

I took a screenshot of the element with selenium, and used Pillow to get a specific single pixel color from each tile that I hoped I would be able to consistently match with an expected tile state. The code looked like this:

def get_tile_color(self, x, y):
    #updated screenshot
    self.get_screenshot()
    # converted number of tiles to pixels
    x = (x * 30) - 15
    y = (x * 30) - 15
    with Image.open(r"board_screenshot.png") as im:
        # tuple contained four values, so the first three are returned
        return tuple(im.getpixel((x,y))[num] for num in range(3))

This approach was not consistent in the RGB values it returned.

2
  • 1
    what is the url? Commented Feb 23, 2023 at 10:17
  • google.com/… Commented Feb 23, 2023 at 21:07

0

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.