1

i know this has been asked before but the last time it has been answered was about a year and a half ago main point is i want to

from selenium import webdriver
from selenium.webdriver.common.keys import Keys



driver =     webdriver.Chrome(executable_path=r'C:\Users\Michelle\Downloads\chromedriver.exe')
username = 'username'
Itemvar1 = driver.execute_script("return prompt('Item name')")

________________

driver.execute_script("window.promptResponse=prompt('Enter smth','smth')")
a = driver.execute_script("var win = this.browserbot.getUserWindow(); return win.promptResponse")


________________

def main():


driver =         webdriver.Chrome(executable_path=r'C:\Users\Michelle\Downloads\chromedriver.exe')


try:
    driver.get("https://www.ebay.com")

    driver.execute_script("window.promptResponse=prompt('Enter smth','smth')")
    Itemvar1 = driver.execute_script("var win = this.browserbot.getUserWindow(); return win.promptResponse")


    input_element = driver.find_element_by_id("gh-ac")
    input_element.send_keys(Itemvar1)
    input_element.send_keys(Keys.ENTER)

    items = driver.find_elements_by_css_selector('.srp-results .s-item .s-item__title')
    prices = driver.find_elements_by_css_selector('.srp-results .s-item .s-item__price')
    auctions = driver.find_elements_by_css_selector('.srp-results .s-item .s-item__purchase-options')

    print("# Items: %d" % len(items))
    print("# Prices: %d" % len(prices))

    num_page_items = len(items)
    for i in range(num_page_items):

        print(items[i].text + " : " + prices[i].text + " " + auctions[i].text )


finally:
    driver.quit()


if __name__ == '__main__':
main()

this code is good but in between the two __ the code that is there does not work properly as i gathered it from old forum point being I'm pretty sure it does not wait till the two java commands are done before continuing to rest which makes the code break can someone help me fix this or come up with an alternative

1

If you use Python input getter, it should work:

text = input("prompt")

OBS: You probably shouldn't relay on user interaction on an automated checking script - the goal of it is exactly this: Perform the checking without wait for user evaluation during its execution.

  • its not exactly what i'm looking for but it will work i was trying to get it to prompt for info on chrome and not python – Kingdomruler10 Dec 11 '18 at 15:19

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.