ZigZig Posted July 16, 2014 Share Posted July 16, 2014 Hello everybody, I'm doing some testing with Selenium WebDriver. Unigui / ExtJS generate html names automatically for id(s): button, input etc.. eg O38_id or id="tab-1048-btnInnerEl" unselectable="on">. I would like to give a name to these ids (eg MyButton1 instead of O38_id). Is there any way to do this. Thank you. Quote Link to comment Share on other sites More sharing options...
Sherzod Posted July 16, 2014 Share Posted July 16, 2014 Hi ZigZig. One way to solve: function beforeInit(sender) { sender.id = "MyButton1"; } But be careful with this approach (there is a chance to give the same ID for multiple objects) ! Try... Best regards. 2 Quote Link to comment Share on other sites More sharing options...
ZigZig Posted July 16, 2014 Author Share Posted July 16, 2014 Hi, It works. Thank you. Best regards. Quote Link to comment Share on other sites More sharing options...
zlatkoi Posted July 17, 2014 Share Posted July 17, 2014 Hi, maybe this will help also. This is python code for clicking buttons and filling edit boxes: def uni_set_element_text(driver, element_name, element_text ): try: s = "//table[contains(@class, '" + element_name + "')]//input[contains(@id, 'inputEl')]" driver.find_element_by_xpath(s).clear() driver.find_element_by_xpath(s).send_keys(element_text) except NoElementPresentException as e: return False return Truedef uni_click_label(driver, element_id): try: s = "//label[contains(@id, '" + element_id + "')]" driver.find_element_by_xpath(s).click() #driver.find_element_by_id(element_id).click() except NoElementPresentException as e: return False return Truedef uni_click_button(driver, element_name): try: s = "//a[contains(@class, '" + element_name + "')]//span[contains(@id, 'btnEl')]" driver.find_element_by_xpath(s).click() except NoElementPresentException as e: return False return Truedef uni_click_pgc_tab(driver, page_control_name, element_caption): try: s = "//div[contains(@class, '" + page_control_name + "')]//span[contains(@id, '-btnInnerEl') and .//text()=" + element_caption + "]" driver.find_element_by_xpath(s).click() #driver.find_element_by_id("tab-1013-btnInnerEl").click() except NoElementPresentException as e: return False return True On Server side i have: procedure TUniForm.UniFrameCreate(Sender: TObject);begin Button.JsControl.Cls := Self.Name + '.' + Button.Name; EditBox.JsControl.Cls := Self.Name + '.' + EditBox.Name;end; Saved me lot of typing in testing Regards, Zlatko 1 Quote Link to comment Share on other sites More sharing options...
ZigZig Posted July 17, 2014 Author Share Posted July 17, 2014 Hi, maybe this will help also. This is python code for clicking buttons and filling edit boxes: def uni_set_element_text(driver, element_name, element_text ): try: s = "//table[contains(@class, '" + element_name + "')]//input[contains(@id, 'inputEl')]" driver.find_element_by_xpath(s).clear() driver.find_element_by_xpath(s).send_keys(element_text) except NoElementPresentException as e: return False return True def uni_click_label(driver, element_id): try: s = "//label[contains(@id, '" + element_id + "')]" driver.find_element_by_xpath(s).click() #driver.find_element_by_id(element_id).click() except NoElementPresentException as e: return False return True def uni_click_button(driver, element_name): try: s = "//a[contains(@class, '" + element_name + "')]//span[contains(@id, 'btnEl')]" driver.find_element_by_xpath(s).click() except NoElementPresentException as e: return False return True def uni_click_pgc_tab(driver, page_control_name, element_caption): try: s = "//div[contains(@class, '" + page_control_name + "')]//span[contains(@id, '-btnInnerEl') and .//text()=" + element_caption + "]" driver.find_element_by_xpath(s).click() #driver.find_element_by_id("tab-1013-btnInnerEl").click() except NoElementPresentException as e: return False return True On Server side i have: procedure TUniForm.UniFrameCreate(Sender: TObject); begin Button.JsControl.Cls := Self.Name + '.' + Button.Name; EditBox.JsControl.Cls := Self.Name + '.' + EditBox.Name; end; Saved me lot of typing in testing Regards, Zlatko Hi, Thanks for sharing. Very helpful. Regards. Quote Link to comment Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.