I am implementing a Python code wherein I need to generate an SHA key. To do this I use an online SHA generator. I send the input (the data for which the Hash is needed), through selenium, which works successfully. However, after that I am unable to get the output that is generated(the text string). I use the find_element_by_xpath function to get this data but it only returns an empty string. I don't understand what i am doing wrong. Can somebody tell me how I can do this? Or if there is any other method, besides using Selenium to achieve this?
I have used the following code:
from selenium import webdriver
from selenium.webdriver.common.by import By
from selenium.webdriver.support.ui import WebDriverWait
from selenium.common.exceptions import TimeoutException
from selenium.webdriver.support import expected_conditions as EC
def driver_init():
driver = webdriver.Chrome(executable_path='chromedriver.exe')
driver.wait=WebDriverWait(driver,5)
return driver
def get_data(driver, val):
driver.get('https://passwordsgenerator.net/sha1-hash-generator/')
xpath='//*[@id="txt1"]'
box=driver.find_element_by_xpath(xpath)
box.send_keys(val)
element=driver.wait.until(EC.presence_of_element_located((By.XPATH, '//*[@id="txt2"]')))
return element.text
driver=driver_init()
w=get_data(driver, '100011')
`