【问题标题】:How do I reference one of the text boxes in this survey to be able to automate typing into them?我如何引用本调查中的一个文本框以便能够自动输入它们?
【发布时间】:2020-04-03 22:57:02
【问题描述】:

  import time
  from selenium import webdriver

  driver = webdriver.Chrome(executable_path=r'C:\WebDrivers\chromedriver_win32 
  (1)\chromedriver.exe')  # Optional argument, if not specified will search path.

  driver.get('https://survey.zohopublic.com/zs/K8CNBt');
  firstName = driver.find_element_by_class_name('inTextBox')
  firstName.send_keys('This is my name')
  # firstName.submit()
  time.sleep(5)  # pause for a bit
  driver.quit()

所以我制作了一个机器人来自动填写此表单以获取更多条目。我只是不知道用什么来引用文本框。我没有可以引用它的集合名称或 ID。我在 selenium 上找不到需要这个文本框的东西。求助?

可以看到代码的网站链接是:https://survey.zohopublic.com/zs/K8CNBt

【问题讨论】:

    标签: python selenium-webdriver bots


    【解决方案1】:

    您可以使用此 xpath (//input[@class=' inTextbox'])[text_box_number] 访问它们。将text_box_number 替换为数字17 以访问文本框First Name Email

    【讨论】:

    • firstName = driver.find_element_by_xpath(//input[@class=' inTextbox'])[1] firstName.send_keys('This is my first name') time.sleep(5)
    • 我做错了吗?我不断收到语法错误
    • 我想通了!我只是有点慢。感谢您的帮助!
    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2015-10-16
    • 1970-01-01
    • 2023-03-21
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多