Can I tell Selenium to record in DOM mode instead of element ID mode?

一曲冷凌霜 提交于 2019-12-08 04:28:40

问题


I have been using Selenium in my DEV environment. When I go to try some of my recorded tests on my Test environment, I find that the elements have different IDs (they are generated by the web framework). I can change the test manually to use

document.forms[2].elements[3]

instead of by id, which looks like this:

ellaMform:j_id77

I'm looking for a way to tell selenium to record the dom:index value for the controls so that tests will be the same between DEV and TEST.

Similar question on SO points to a plugin but is not exactly what I need: Make Selenium record IDs, not paths


回答1:


IDE already has locator builders for several DOM styles (e.g., dom:index, which matches your model, or dom:name, which is less position-oriented). By default, they are prioritized lower than ID locators, but you can choose which locator you want to use when you record the test.



来源:https://stackoverflow.com/questions/6207454/can-i-tell-selenium-to-record-in-dom-mode-instead-of-element-id-mode

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!