Closed namratar2106 closed 1 year ago
Hi @namratar2106,
Thanks for your information here. In your scenarios, you need to select the page tab from the page tab list, but meet exception if current page tab contains the same name element, right?
from your code snippet:
element = driver.find_element_by_role("page tab list").select("Language")
print(element.role)
The JABElement "page tab list" available to select child JABElement in here but will not return anything here. So the variable your named "element" is None and has no attribute "role", that's the reason exception occurs. Your can reference with "select" function from pyjab/jabelement.py => select
def select(self, option: str, simulate: bool = False, wait_for_selection: bool = True) -> None:
"""Select an item from JABElement selector.
Support select action from combo box, page tab list, list and menu.
Args:
option (str): Item selection from selector.
simulate (bool, optional): Simulate user input action by mouse event. Defaults to False.
wait_for_selection (bool, optional): Waits for selection equal to the option value. Defaults to True.
"""
_ = {
"combo box": self._select_from_combobox,
"page tab list": self._select_from_page_tab_list,
"list": self._select_from_list,
"menu": self._select_from_menu,
}[self.role_en_us](option=option, simulate=simulate)
if wait_for_selection:
self._wait_for_value_to_contain([States.SELECTED, States.CHECKED],
self.find_element_by_name(option).states_en_us)
My application has a page tab list and inside it has 4 page tabs. Parameter Definition, Software, Language and Phonebook Inside Parameter Definition and Language page tabs there is a label with the same name as of tab title Code to select the Language tab: element = driver.find_element_by_role("page tab list").select("Language") print(element.role) The above code throws timeout exception and prints element.role as label instead it should be page tab. Code works fine for Software and Phonebook page as there are no labels matching with the Tab <img width="239" alt="Capture" src="https://user-images.githubusercontent.com/115481757/194891783-61e4c383-b7de-4ad7-acb3-84
0ace162614.PNG">