Sugeestions on Dynamic XPATH in PageFactory Selenium JVM

32 views
Skip to first unread message

skumar...@gmail.com

unread,
Apr 16, 2019, 4:15:55 PM4/16/19
to Selenium Users
Guys, 

Any suggestions on Dynamic XPATH in PageFactory Selenium JVM.


Mallichetty Hemanth Kumar

unread,
Apr 17, 2019, 12:25:19 AM4/17/19
to Selenium Users
hello 

which element u want to make dynamic, please upload the DOM and with details
Message has been deleted

Mallichetty Hemanth Kumar

unread,
Apr 17, 2019, 12:53:24 PM4/17/19
to seleniu...@googlegroups.com, skumar...@gmail.com
Hi


Can you text me in WhatsApp


On Wed, Apr 17, 2019, 8:01 PM <skumar...@gmail.com> wrote:

String searchKey = searchUser.replace("@werner.com", "");
WebElement dynamicActionOption = driver.findElement(By.xpath("(//table[@id='carrier-details-table']//tbody//tr)//td[1]//ancestor::tr//td[4]//a[contains(text(),'" + searchKey + "')]//ancestor::tr//td[7]//button[@id='action-options'][@aria-haspopup='true']"));
System.out.println("Actionoption Expanded dialogue: " + dynamicActionOption.getAttribute("aria-expanded"));


I am now using this as a part of implementation; I couldnt add this in pagefactory @Findby as it uses a constant xpath cant send variable. 

--
You received this message because you are subscribed to the Google Groups "Selenium Users" group.
To unsubscribe from this group and stop receiving emails from it, send an email to selenium-user...@googlegroups.com.
To post to this group, send email to seleniu...@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/selenium-users/86fde1b5-882e-48b7-ac63-924417679d84%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

skumar...@gmail.com

unread,
Apr 17, 2019, 1:05:44 PM4/17/19
to Selenium Users

String searchKey = searchUser.replace("Variable", "");
WebElement dynamicActionOption = driver.findElement(By.xpath("(//table[@id='details-table']//tbody//tr)//td[1]//ancestor::tr//td[4]//a[contains(text(),'" + searchKey + "')]//ancestor::tr//td[7]//button[@id='action-options'][@aria-haspopup='true']"));

System.out.println("Actionoption Expanded dialogue: " + dynamicActionOption.getAttribute("aria-expanded"));

This is written as a part of the class file not in PageFactory @FindBy uses only contact Xpath. 


On Tuesday, April 16, 2019 at 11:25:19 PM UTC-5, Mallichetty Hemanth Kumar wrote:
Reply all
Reply to author
Forward
0 new messages