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

asked Dec 11, 2018 at 4:27

1 Answer 1

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.

answered Dec 11, 2018 at 5:27
1
  • 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 Commented Dec 11, 2018 at 15:19

Your Answer

Draft saved
Draft discarded

Sign up or log in

Sign up using Google
Sign up using Email and Password

Post as a guest

Required, but never shown

Post as a guest

Required, but never shown

By clicking "Post Your Answer", you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.