Can not choose button with the same name (Windows)
I have two buttons with the same name in Windows program. So I do: "self.driver.find_element_by_name("button name").click()" - it selects the first one, but I need the second one.
I tried to use Inspect.exe to find AutomationId, but in the case it doesn't show AutomationId. There are name, processId etc
So how to choose the second button? Thanks!
- Appium python client version: 0.46
- Desktop OS/version used to run Appium: Ubuntu 18.04
- Platform/version under test: Windows Server 2016
- Real device or emulator/simulator: VPS
Instead of running the click straight away you can iterate over the results and see if they are suitable before clicking them.
foreach (button in self.driver.find_elements_by_name("button_name")) if button.property == 'what i want' button.click()
You can add other constraints on the button by adjusting the if statements. Nothing inside the foreach will run if there are no matching buttons.