Home > Enterprise >  Why does Playwright not change url once button is clicked on Uber Eats?
Why does Playwright not change url once button is clicked on Uber Eats?

Time:12-21

Essantially, I want to enter an address into uber eats and go on to the next page. However, I have noticed that the url isn't actually changing once the button is clicked.

from playwright.sync_api import sync_playwright

with sync_playwright() as p:
    browser = p.chromium.launch()
    page = browser.new_page()
    page.goto("https://www.ubereats.com/ca")
    print(page.title())
    page.fill("#location-typeahead-home-input", "address")
    page.keyboard.press("Enter")
    print(page.url)
    page.close()

I have tried doing the same thing by specifically targeting the "Find Food" button on the landing page. For some reason, this doesn't actually change the page. Help would be appreciated, thank you!

CodePudding user response:

I have come up with a solution in Node js puppeteer and I think it work the same way in python. As far as why the button isn't being pressed, I have no idea. But, what does work is entering an address and then clicking the first address suggestion.

Here is my code:

const puppeteer = require('puppeteer');
async function start(){
    const browser = await puppeteer.launch()
    const page = await browser.newPage()
    await page.goto("https://www.ubereats.com/ca")
    await page.type("#location-typeahead-home-input", "Address")
    await page.waitForSelector('#location-typeahead-home-item-0');
    await page.click("#location-typeahead-home-item-0")
    await page.waitForNavigation()

    console.log(page.url())
    await browser.close()
}

start()

CodePudding user response:

There is a bug on the page, if you type address too fast and press Enter before the dialog appears, it will not navigate. See this comment.

  • Related