Reputation: 1071
Issue: Unable to select an element id object using a stored variable.
Situation: I need to open a page, make a selection, store that selection in a variable card_id
and next, find the element on the last page with the id pick_id
and the stored variable, and click it. Hope I am being clear on this situation. If not, please just ask. I have tried to find the Selenium API documentation to handle this, nope.
Test Code:
def test_00_validation_test(self):
driver = self.driver
driver.get(self.base_url)
driver.find_element_by_id("first_page").click()
driver.find_element_by_id("make_pick").click()
driver.find_element_by_xpath("(//input[@name='64'])[2]").click()
driver.find_element_by_id("save_pick").click()
self.assertEqual("Pick Was Saved", self.close_alert_and_get_its_text())
card_id = driver.find_element_by_id("testingNum").get_attribute("value")
driver.find_element_by_id("confirm_pick_page").click()
driver.find_element_by_id("pick_id", card_id).click()
Upvotes: 0
Views: 2013
Reputation: 2247
Ok from your explanation i think you want to go the element pick_id then drill down and look for card_id and click on it. This could be done as:
card_id = driver.find_element_by_id("testingNum").get_attribute("value")
pick_id = driver.find_element_by_id("pick_id")
pick_id.find_element_by_id(card_id).click()
You can always find an element and then drill down that element using find_element_by
.
Upvotes: 1