0

The code I wrote is very basic and it simply works. It takes a value on the Selenium-related site, writes it to a txt, then reads the necessary part of the value and should sound an alarm according to this value. The code terminates before reaching the alarm part or it does not see the alarm part. The problem here may be related to the value I got from the txt, but I could not solve the problem despite my attempts. How can I solve this? note:There is no problem with the vlc library, it works when used separately and in this example the value in the txt is 12 feb 2022 and it only reads the first character

from selenium import webdriver
import time
import vlc

driver = webdriver.Chrome()
driver.get("https://demoqa.com/automation-practice-form")
driver.maximize_window()
print("Site Title:",driver.title)

#####################################################

nameElement =driver.find_element_by_id("dateOfBirthInput")
nameElement.click()
time.sleep(5)

taleptAttribute = nameElement.get_attribute('value')
print(taleptAttribute)
#print("Talep Sayısı: " + nameElement.get_attribute('value'))

################################################################

talep_satırı = open("talep_satiri.txt", "w")
talep_satırı.write(taleptAttribute)


talep_satırı = open("talep_satiri.txt","r")
talepsayisi=talep_satırı.read(1)
print(talepsayisi)

alarm = vlc.MediaPlayer("path")

if (talepsayisi == 1 ):
   alarm.play()
   time.sleep(10)
   alarm.stop()
else:
   alarm.play()


  • talepsayisi is what type? a string doesn't equal to numerical value of 1. – Arundeep Chohan Feb 12 '22 at 18:37
  • talepsayisi is a string for example 12 feb 2022 but I use it by taking int(number of requests) as an integer and reading its first value –  Feb 12 '22 at 18:40

0 Answers0