1

Need to input the value "Users" from drop down and click the create button

from selenium.webdriver.support import expected_conditions as EC
from selenium.webdriver.support.ui import WebDriverWait
from selenium import webdriver
from selenium.webdriver.common.by import By
from selenium.webdriver.support.ui import Select

EMAILFIELD = (By.ID, "username")
PASSWORDFIELD = (By.ID, "password")
LOGINBUTTON = (By.ID, "Login")
CLICKBUTTON= (By.ID, "thePage:rtForm:createButton")
QUICKFINDSEARCH = (By.ID, "quickFindInput")

browser = webdriver.Chrome(
    executable_path=r"C:/Users/RYadav/AppData/Roaming/Microsoft/Windows/Start Menu/Programs/Python 3.8/chromedriver.exe")
browser.get('https://fleet.my.salesforce.com/')

# wait for email field and enter email
WebDriverWait(browser, 5).until(EC.element_to_be_clickable(EMAILFIELD)).send_keys("ryadav@gmail.com")

# wait for password field and enter password
WebDriverWait(browser, 5).until(EC.element_to_be_clickable(PASSWORDFIELD)).send_keys("1234zxcvb")

# Click Login - same id?
WebDriverWait(browser, 5).until(EC.element_to_be_clickable(LOGINBUTTON)).click()

#direct new reportfield
browser.get('https://fleet.my.salesforce.com/reportbuilder/reportType.apexp')

#search the Users from dropdown and click button
select = Select(webdriver.find_element_by_id("quickFindInput"))
select.select_by_visible_text("Users")
WebDriverWait(browser, 5).until(EC.element_to_be_clickable(CLICKBUTTON)).click()

Please suggest how to input a value from dropdown to the above code. This code throws Attribute Error.

    Traceback (most recent call last):
  File "C:/Users/RYadav/PycharmProjects/ElementProject/SalesforceUrl.py", line 30, in <module>
    select = Select(webdriver.find_element_by_id("quickFindInput"))
AttributeError: module 'selenium.webdriver' has no attribute 'find_element_by_id'
undetected Selenium
  • 183,867
  • 41
  • 278
  • 352
ruchi yadav
  • 41
  • 2
  • 8

1 Answers1

1

You were so close. Through out your program you had been using browser as the WebDriver instance. But called through a differnt name webdriver in the line:

select = Select(webdriver.find_element_by_id("quickFindInput"))

You need to change the line as:

select = Select(browser.find_element_by_id("quickFindInput"))
undetected Selenium
  • 183,867
  • 41
  • 278
  • 352
  • It's throwing no error but it's not picking the "Users" value and clicking the create button there. The purpose is still not fulfilled. Kindly suggest – ruchi yadav Jun 25 '20 at 17:36
  • @ruchiyadav This answer was to address the issue of `AttributeError: module 'selenium.webdriver' has no attribute 'find_element_by_id'` nothing more then that. – undetected Selenium Jun 25 '20 at 17:41
  • Thank you. I will be really grateful if you could suggest more on the search box query. How should it be done – ruchi yadav Jun 25 '20 at 19:50
  • @ruchiyadav Actually, while writing the answer I took an attempt to login using the credentials you have published but my login attempts were not successful. Else I would had given it even before you had asked it :) – undetected Selenium Jun 25 '20 at 19:53
  • 1
    @ruchiyadav If it is a ` – undetected Selenium Jun 25 '20 at 19:58
  • the above guide line worked to the part of input "user"' as a value . Now to select the "Users" value from suggestion list is inside the span. How it should be handled, please guide with this. Let me know if any thing needed in addition for this requirement. – ruchi yadav Jul 15 '20 at 07:43
  • @ruchiyadav Can you raise a new question with your new requirement please? – undetected Selenium Jul 15 '20 at 07:46