0

Selecting the value from the dropdown which has a select tag in Selenium. However, I am getting the following error while selecting the value from the dropdown.

Her is my Code:

    from selenium.webdriver.common.by import By
    from selenium.webdriver.support.select import Select
    import time
    from Pages.BasePage import Common
    from configration.config import Data
    
    
    class OrderCycle(Common):
        # By Locator
        
        US_State = (By.XPATH, "//option[@value='AL']")
       
    
        # Constructor of the page class
    
        def __init__(self, driver):
            # super().__init__(driver)
            self.driver = driver
            self.driver.get(Data.Base_url)
        # Page Action for Order cycle
    
      
        # Select the state from the Dropdown.
        def select_state(self):
            self.do_click(self.US_State), Select(self.US_State).select_by_visible_text("Alabama")

Actual Result:

FAILED Test/test_CartItem.py::TestOrder::test_select_product[chrome] - AttributeError: 'tuple' object has no attribute 'tag_name'
FAILED Test/test_CartItem.py::TestOrder::test_select_product[firefox] - AttributeError: 'tuple' object has no attribute 'tag_name'
4
  • Which library are using for Common? Commented Dec 7, 2020 at 13:14
  • Maximilian Peters: This is not a library, This is my class name that Inherited in OrderCylce class. Here is the code: class Common: def __int__(self, driver): self.driver = driver def do_click(self, by_locator): WebDriverWait(self.driver, 30).until(EC.visibility_of_element_located(by_locator)).click() def do_send_keys(self, by_locator, text): WebDriverWait(self.driver, 10).until(EC.visibility_of_element_located(by_locator)).send_keys(text) Commented Dec 7, 2020 at 13:20
  • Your code does not contain the failing test. Please consider providing a minimal reproducible example reproducing the error. Most probably an unnecessary comma was placed somewhere in a return statement. Commented Dec 7, 2020 at 14:33
  • Can you add all the code to your question? Commented Dec 7, 2020 at 22:03

1 Answer 1

1

Removing the Brackets and it worked now. US_State = By.XPATH, "//option[@value='AL']"

Sign up to request clarification or add additional context in comments.

Comments

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.