0

how can i call a javascript function in Selenium Python?

I'm trying to click on a button like this:

<a href="javascript:;" class="btndefault j-open-game j-gamingButton" data-gameid="1280" data-productid="2" ...> 

But if i search it with:

btn = browser.find_element_by_class_name('btndefault j-open-game j-gamingButton')

I receive:

selenium.common.exceptions.NoSuchElementException: Message: no such element: Unable to locate element: {"method":"css selector","selector":".btndefault j-open-game j-gamingButton"}

if i search it with:

btn = browser.find_element_by_xpath("//button[@name='j-gamingButton']")

I receive:

selenium.common.exceptions.NoSuchElementException: Message: no such element: Unable to locate element: {"method":"xpath","selector":"//button[@name='j-gamingButton']"}

if i search it with:

btn = browser.find_element_by_xpath("//button[@name='j-btndefault j-open-game j-gamingButton']")

I receive:

selenium.common.exceptions.NoSuchElementException: Message: no such element: Unable to locate element: {"method":"xpath","selector":"//button[@name='j-btndefault j-open-game j-gamingButton']"}

if i search it with:

btn = browser.find_element_by_xpath("//button[@class='j-btndefault j-open-game j-gamingButton']")

I receive:

selenium.common.exceptions.NoSuchElementException: Message: no such element: Unable to locate element:

Do you have any suggestions for me? Thanks in advance

2
  • stackoverflow.com/questions/48732196/… Commented May 7, 2020 at 16:01
  • Is it possible you're looking for elements in the wrong context? for instance are these elements in an iframe? Commented May 7, 2020 at 18:36

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.