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("[email protected]")

# 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'

1 Answer 1

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"))
Sign up to request clarification or add additional context in comments.

7 Comments

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
@ruchiyadav This answer was to address the issue of AttributeError: module 'selenium.webdriver' has no attribute 'find_element_by_id' nothing more then that.
Thank you. I will be really grateful if you could suggest more on the search box query. How should it be done
@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 :)
@ruchiyadav If it is a <select> node you were on the right track. However I would suggest while invoking click() or send_keys() always induce WebDriverWait with the expected_conditions set as element_to_be_clickable()
|

Your Answer

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.