Closed DuXspace closed 3 years ago
Hi @DuXspace , to access using XPATH to a subbelement inside a parent one, a relative path must be used, like .//input[contains(@Class, 'mode-input')]
that searches from parent node, instead of an absolute one, like //input[contains(@Class, 'mode-input')]
that searches from root node.
This is not about Toolium or Selenium, it is an XPATH design, as can be seen in this Selenium discussion: https://github.com/seleniumhq/selenium-google-code-issue-archive/issues/403
Hello @rgonalo , aahh, yes you're right, my mistake, sorry for disturbing, i forgot to add dot. As I understand it doesn't work for classes inherited from Group like in Case2, because parent will be that selector "//div[contains(@Class, 'modal-body')]", am i right?
Yes, you are right, now an element in a group can not have a custom parent. But I think that could be a useful feature and it would just work with this PR #240.
@rgonalo thank you! waiting for review
The change is already merged and included in the new release 2.1.1: https://github.com/Telefonica/toolium/releases/tag/2.1.1
Example of html code: https://61377283aa57c.htmlsave.net/
Case1: In this case first input will be filled, but we selected second element by xpath:
`class Page(PageObject): group_show_block = PageElement(By.XPATH, "//div[@class='modes-block'][2]") topic_input = InputText(By.XPATH, "//input[contains(@class, 'mode-input')]", parent=group_show_block)
Page().topic_input.text = "Hello"`
Case2: Parent argument doesn't work, you can write class that not exist in group_show_block and first input wil be filled,
`class GroupTicketShowModal(Group): group_show_block = PageElement(By.XPATH, "//div[@class='modes-block'][2]") topic_input = InputText(By.XPATH, "//input[contains(@class, 'mode-input')]", parent=group_show_block)
class Page(PageObject): group_ticket_show_modal = GroupTicketShowModal(By.XPATH, "//div[contains(@class, 'modal-body')]")`
Page().group_ticket_show_modal.topic_input.text = "Hello"`