I m working on project that uses SpeechRecognition and selenium to automatize my things, and I have these 2 function 1 to open and other to click, but the click does not work, even when I
m на странице с тем же xpath, почему это так? я должен сделать бездействие ждет? Я пытался найти некоторые коды, подобные моему, но безуспешно, функция, которая имеет проблему, называется includeir
class voice_rec:
def __init__(self):
self.IV_lingua= "pt-BR"
self.IV_webdriver = 'Chromedriver/chromedriver.exe'
self.driver = None
def abre_contabilidade(self, sleep=1):
self.driver = webdriver.Chrome(self.IV_webdriver)
time.sleep(sleep)
self.driver.get('http://127.0.0.1:2020/CTP/')
def incluir(self):
self.driver.find_element_by_xpath('/html/body/form/div/nav/div/ul/li[1]/a')
def abre_folha(self, sleep=1):
driver = webdriver.Chrome(self.IV_webdriver)
time.sleep(sleep)
driver.get('http://127.0.0.1:2020/FPG/')
def voice_recognition(self):
r = sr.Recognizer()
with sr.Microphone() as source:
print("Speak:")
r.adjust_for_ambient_noise(source)
audio = r.listen(source)
try:
text = r.recognize_google(audio, language=self.IV_lingua)
print("you said : {}".format(text.lower()))
if text.lower() == "alô":
print("comando recebido")
elif "abra contabilidade" in text.lower():
print('ok')
voice_rec().abre_contabilidade()
elif "abra a folha" in text.lower():
voice_rec().abre_folha()
elif "inclua registro" in text.lower():
voice_rec.incluir()
except:
print('Sorry could not recognize')
a = voice_rec()
while True:
a.voice_recognition()
введите описание изображения здесь