Selenium Python Tutorial #33 - How to execute JavaScript in Selenium

แชร์
ฝัง
  • เผยแพร่เมื่อ 23 ม.ค. 2025

ความคิดเห็น • 18

  • @facundoregalado5334
    @facundoregalado5334 2 ปีที่แล้ว +2

    I was struggling to click an element that was not interactable with python, executing this script with JavaScript solved it. Thank you a lot.

  • @lvnd4556
    @lvnd4556 2 ปีที่แล้ว +1

    I'm searching for this answers for almost a week. Great stuff!

  • @kobansame6754
    @kobansame6754 ปีที่แล้ว

    Just the tutorial I wanted. Thanks.

  • @ВіталійГлапшун
    @ВіталійГлапшун 2 ปีที่แล้ว +1

    Great explanation, Sir! Thank you 💙💛

  • @Jetseoo
    @Jetseoo 2 ปีที่แล้ว +1

    Thanks! You helped me!

  • @makoj1892
    @makoj1892 2 ปีที่แล้ว +1

    Thank you so much!!!!

  • @czajnik_gaming5313
    @czajnik_gaming5313 2 ปีที่แล้ว +1

    thank you that really helped me :)

  • @vladimir_peace
    @vladimir_peace ปีที่แล้ว

    I get Javascript exception error:
    selenium.common.exceptions.JavascriptException: Message: javascript error: Cannot read properties of undefined (reading 'click')
    I use the same "click" script
    driver.execute_script("arguments[0].click();", demo_element)
    But I used a different script to select the element on a different website (it works (finds the element) on the website)
    demo_element = driver.execute_script("return document.getElementsByTagName('a')[6];")
    Why the exception happens? How to fix it?

  • @paulfogoros4570
    @paulfogoros4570 3 ปีที่แล้ว +1

    Hi sir. I have a javascript file (with variables & functions). I load and execute the file with driver.execute_script open.file.read, everything is good, but if I try to acces a variable from executed block code, I get "can't find variable x", and that variable I declared on the js file. Any idea?

    • @NicolasChanCSY
      @NicolasChanCSY 2 ปีที่แล้ว +1

      @Paul Fogoros I think the problem is that the JS is run in your browser's console, not in your Python. Hence, it is natural that Python cannot get that variable x, because Python is not responsible for it for its whole lifetime.
      You may use `driver.execute_script("return xxx;")` to get some return values. But I am not sure if you can retrieve values of any executed script in this way. I am interested to know the results if you try it out.

  • @AnilRathod-zh3iu
    @AnilRathod-zh3iu 2 ปีที่แล้ว

    Namastay sir, unable to write the path using the java_scrypt
    if u have posted any tutorial for that please share

  • @ravideshnur7734
    @ravideshnur7734 2 ปีที่แล้ว

    Hi all ,am getting an exception JavascriptException: Message: javascript error: arguements is not defined ,can anyone help me out to overcome this exception.

  • @tarnished9581
    @tarnished9581 2 ปีที่แล้ว +1

    Treasure

  • @agoogleuser3402
    @agoogleuser3402 3 ปีที่แล้ว

    Hello sir.

    • @softwaretestingmentor
      @softwaretestingmentor  3 ปีที่แล้ว

      Hello there!

    • @agoogleuser3402
      @agoogleuser3402 3 ปีที่แล้ว

      @@softwaretestingmentor sir I need java logic to scroll down two Times down for infinite scroll using selenium. I'm using javascript executor, but I am unable to scroll down using the scroll methods. Can you help me please? I have seen a python code, but how to convert it into java?