Execute Javascript using Selenium Python - Part 13

แชร์
ฝัง
  • เผยแพร่เมื่อ 20 ต.ค. 2024
  • In this video, I have explained how to execute javascript code using selenium python.
    It may so happen in some real time projects, Selenium WebDriver is not able to perform some action on a particular web element and interacting with web elements through Javascript was the only possible solution.
    ~~~~Subscribe to this channel, and press bell icon to get some interesting videos on Selenium and Automation:
    www.youtube.co...
    Follow me on my Facebook Page:
    / naveenqtpexpert
    Let's join our Automation community for some amazing knowledge sharing and group discussion on Telegram:
    t.me/joinchat/...
    Paid courses (Recorded) videos:
    naveenautomati...
    For Java & Selenium - naveenautomatio...
    For API (Manual + Automation) - naveenautomatio...

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

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

    Very well explained , Helpful..Thank you

  • @MDHOSSAIN-gj5ve
    @MDHOSSAIN-gj5ve 4 ปีที่แล้ว

    Excellent job done by Naveen Sir , the master of Automation

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

    Good Job Naveen

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

    Hi Naveen How click on ag-grid table can you please explain

  • @johndoe-lz8fo
    @johndoe-lz8fo 2 ปีที่แล้ว

    hi, this video was greatly helpful. but is there a way to click on a video and scroll through the video using execute_script? or something in selenium?

  • @АлександрНохрин-щ3в
    @АлександрНохрин-щ3в 2 ปีที่แล้ว

    Hello Naveen!
    Thanks a lot for your job.
    Will you explain on moving to the top of the page - why did you put window height on x-coordinate? I belive that (0, 0) coordinates will work. Am I wrong here?

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

    Hey Naveen, is this also an important topic in JS executor- executeAsyncScript?

  • @crickettales6594
    @crickettales6594 4 ปีที่แล้ว +1

    Naveen it was working for me if I am using print and putting the driver part in it

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

    Hi Naveen,
    The sendKeys with JavaScriptExecutor is working as below. I have tried the same on the hubspot application.
    username=driver.find_element(By.ID,'username')
    driver.execute_script("arguments[0].value='amol.nawale';",username)

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

      Thanks for the answer!! How can i pass the value dynamically?

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

      For dynamically
      driver.execute_script("document.getelementbyid("idbusca").value=" + (dynamically))

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

    some sites says access denied when refresh by history.go(0) also some scripts don't work. Any solution for that?

  • @armandcompar1197
    @armandcompar1197 4 ปีที่แล้ว

    Do you know why scrollTo is not working in browser console and python. I tested in browser with different data window.scrollTo(0,800); and changed the 800 to other number and still it did nothing. Python not scrolling as well. Tested in chrome

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

      def scroll(self, down=0): # it will go down and up according to your choice 1 or by default 0 value
      """This method will be used to scroll up and down to any page"""
      self.driver.find_element_by_tag_name('html').send_keys(Keys.END)
      if down == 1:
      print("")
      time.sleep(3)
      else:
      time.sleep(5)
      self.driver.find_element_by_tag_name('html').send_keys(Keys.HOME)
      # self.driver.execute_script("window.scrollTo(0,500)")

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

    now the command to scroll down a yourtube page is:
    driver.execute_script("window.scrollTo(0, document.documentElement.scrollHeight)")

  • @Barry_junglebeats
    @Barry_junglebeats 4 ปีที่แล้ว

    Hi Naveen. Can you please demo how to handle a calendar using with the help of selenium and Javascript using Python?
    Awaiting your response.
    Thanks in advance!

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

      Haii Bharat Kumar,
      Can u give hint about this, I have to pic date in calendar using python

  • @yesjay1335
    @yesjay1335 4 ปีที่แล้ว

    Hi Naveen, I can't able to join ur telegram group...

  • @rahulpawar7726
    @rahulpawar7726 4 ปีที่แล้ว

    Hello Naveen,
    Thanks for explaining the JS method.
    I tried it on the same application for send value to the textbox.
    email = driver.find_element(By.ID, 'username')
    driver.execute_script("document.getElementById('username').value='rahul_pawar', email;")

    • @mfabuthahir1
      @mfabuthahir1 10 หลายเดือนก่อน

      # Selenium data sending
      driver.find_element(By.ID, "ta1").send_keys("Sigma Male")
      # Javascript data sending
      text_box_field = driver.find_element(By.ID, "ta1")
      driver.execute_script("arguments[0].value='Sigma Male'", text_box_field)

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

    Can anyone suggest how to input text/value using javascript in Robot framework?
    I have tried this, but not working.
    Execute Javascript arguments[0].value='123'; xpath

  • @chakradharreddy8650
    @chakradharreddy8650 4 ปีที่แล้ว

    Hi Naveen,
    Thank you for the tutorials, getting to learn a lot from these.
    Can you please add a tutorial to handle date picker/calendar as it is a very important use case these days?

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

      Haii chakradhar reddy,
      Can u give hint about this, I have to pic date in calendar using python

    • @mfabuthahir1
      @mfabuthahir1 10 หลายเดือนก่อน

      driver.get("seleniumpractise.blogspot.com/2016/08/how-to-handle-calendar-in-selenium.html")
      # Javascript code
      calender_field = driver.find_element(By.ID, "datepicker")
      driver.execute_script("arguments[0].value='04/12/2024'", calender_field)

  • @shikhakajal3580
    @shikhakajal3580 4 ปีที่แล้ว

    Hi Naveen
    Please make videos on nightwatch as well.🙏
    Thank you in advance 😊