there is a website (company website - cant share login) which has a search box containing locations
i was using fill to type in a randomly selected location from a dictionary
playwright fill in the entire location all at once
---
but the website search bar bugs out if u type in the all string at once.
only way to prevent the search bar from bugging out is type in each char
(i tried asking website owners to fix the search bar they dont seem interest)
i tired to following code but it keeps bugging out
parts of the code related to the search bar
import random
import time
import sys
random10 = ""
lda_10 = {
1: "bahria town - overseas A",
2: "bahria town - awais qarni block",
3: "bahria town - shaheen block",
4: "bahria town - shaheen block extension",
5: "bahria town - Ghouri block",
6: "bahria town - takbeer block",
7: "bahria town - Gulbahar Block",
}
def R_10():
global random10
random10 = random.choice(list(lda_10.values()))
for l in random10:
sys.stdout.write(l)
sys.stdout.flush()
time.sleep(0.2)
page.locator("#location_id_input").fill(random10)
page.locator("(//ul)[8]/li[1]").click
i expected the code to type in the chars but it just does not work
You could try to use page.type. It sends the events like a user typing on a keyboard would and you can also set a timeout to simulate a delay like a user would have.
await page.type("#location_id_input", random10, {delay: 100});