healenium / healenium-web

Self-healing library for Selenium Web-based tests
Apache License 2.0
170 stars 40 forks source link

[BUG]: css locator is not working inside form #195

Closed mpchethan closed 2 years ago

mpchethan commented 2 years ago

Describe the bug

<form id="headerForm" <label id="headerForm

Healenium generated locator is label#headerForm is not working getting error org.openqa.selenium.InvalidSelectorException: invalid selector: An invalid or illegal selector was specified

is it possible get xpath instead of css locator from healenium

How to reproduce the issue

<form id="headerForm"
        <label id="headerForm

Healenium generated locator is label#headerForm is not working getting error org.openqa.selenium.InvalidSelectorException: invalid selector: An invalid or illegal selector was specified

is it possible get xpath instead of css locator from healenium

Logs appeared during using Healenium

org.openqa.selenium.InvalidSelectorException: invalid selector: An invalid or illegal selector was specified

Expected behavior

No response

Actual behavior

No response

Healenium Web version

3.2.5

Healenium Backend version

3.2.2

Selenium version

4.1.2

Platform

java

Properties file

recovery-tries=1 score-cap=.6 heal-enabled=true serverHost = localhost serverPort = 7878

Additional context

No response

mpchethan commented 2 years ago

Hi Team,

can you please help me.... is there way to generate xpath locator from healenium instead of css because css locators are not working inside form tag

ElenaStepuro commented 2 years ago

Hello @mpchethan , what do you mean?

mpchethan commented 2 years ago

css locator generated by healenium like label#headerForm is not working inside form tag.. can you please suggestion

mpchethan commented 2 years ago

tried manually also css inside form tag is not working

mpchethan commented 2 years ago

its in our application only css with id location is not working..

Alex-Reif commented 2 years ago

Hi @mpchethan , Issue was fixed in the hlm-web 3.3.0

mpchethan commented 2 years ago

I will try and let you know and one more query how to generate xpath instead of css

Thanks

Sent from my iPhone

On 12-Aug-2022, at 2:50 PM, Aliaksei-Ashukha @.***> wrote:

 Hi @mpchethan , Issue was fixed in the hlm-web 3.3.0

— Reply to this email directly, view it on GitHub, or unsubscribe. You are receiving this because you were mentioned.

Alex-Reif commented 2 years ago

@mpchethan , Priority of healed locator type based on client type. In case you use By.xpath("old"), selector-imitator will try to build new healed element By.xpath as well. ( By.xpath("new") ), otherwise will be use css locator type.

mpchethan commented 2 years ago

Ok, thanks.

On Fri, Aug 12, 2022 at 6:39 PM Aliaksei-Ashukha @.***> wrote:

@mpchethan https://github.com/mpchethan , Priority of healed locator type based on client type. In case you use By.xpath("old"), selector-imitator will try to build new healed element By.xpath as well. ( By.xpath("new") ), otherwise will be use css locator type.

— Reply to this email directly, view it on GitHub https://github.com/healenium/healenium-web/issues/195#issuecomment-1213093934, or unsubscribe https://github.com/notifications/unsubscribe-auth/AHOZTLNCQGNJ5IWMPFCKGYDVYZEKNANCNFSM55BLN5LA . You are receiving this because you were mentioned.Message ID: @.***>

mpchethan commented 2 years ago

Hi ,

not working getting error

java.lang.NoSuchMethodError: org.jsoup.nodes.Document.root()Lorg/jsoup/nodes/Node; at com.epam.healenium.treecomparing.JsoupHTMLParser.parse(JsoupHTMLParser.java:25) at com.epam.healenium.SelfHealingEngine.parseTree(SelfHealingEngine.java:121) at com.epam.healenium.processor.HealingProcessor.execute(HealingProcessor.java:32) at com.epam.healenium.processor.BaseProcessor.process(BaseProcessor.java:41) at com.epam.healenium.processor.BaseProcessor.process(BaseProcessor.java:49) at com.epam.healenium.processor.BaseProcessor.process(BaseProcessor.java:49) at com.epam.healenium.handlers.proxy.BaseHandler.findElement(BaseHandler.java:58) at com.epam.healenium.handlers.proxy.SelfHealingProxyInvocationHandler.invoke(SelfHealingProxyInvocationHandler.java:39) at com.sun.proxy.$Proxy22.findElement(Unknown Source) at org.openqa.selenium.support.pagefactory.DefaultElementLocator.findElement(DefaultElementLocator.java:70) at org.openqa.selenium.support.pagefactory.internal.LocatingElementHandler.invoke(LocatingElementHandler.java:39) at com.sun.proxy.$Proxy29.click(Unknown Source)

pure test is passed .

before fixes ..css locator were generating but now error

com.epam.healenium healenium-web 3.3.0

Thanks, Chethan

On Fri, Aug 12, 2022 at 8:34 PM Chethan shetty @.***> wrote:

Ok, thanks.

On Fri, Aug 12, 2022 at 6:39 PM Aliaksei-Ashukha @.***> wrote:

@mpchethan https://github.com/mpchethan , Priority of healed locator type based on client type. In case you use By.xpath("old"), selector-imitator will try to build new healed element By.xpath as well. ( By.xpath("new") ), otherwise will be use css locator type.

— Reply to this email directly, view it on GitHub https://github.com/healenium/healenium-web/issues/195#issuecomment-1213093934, or unsubscribe https://github.com/notifications/unsubscribe-auth/AHOZTLNCQGNJ5IWMPFCKGYDVYZEKNANCNFSM55BLN5LA . You are receiving this because you were mentioned.Message ID: @.***>

Alex-Reif commented 2 years ago

@mpchethan , What version of org.jsoup do you use? Recomended version 1.11.3

mpchethan commented 2 years ago

Ok I will try

Sent from my iPhone

On 15-Aug-2022, at 4:16 PM, Aliaksei-Ashukha @.***> wrote:

 What version of org.jsoup do you use? Recomended version 1.11.3

— Reply to this email directly, view it on GitHub, or unsubscribe. You are receiving this because you were mentioned.

mpchethan commented 2 years ago

this is old xpath - Failed to find an element using locator By.xpath: @.***='headerForm:prodNewId2'] Healenium generated CSS is findElements {using=css selector, value=a#headerForm:prodNewId3}]

we need xpath instead of CSS

problem not resolved.

Thanks, Chethan

On Mon, Aug 15, 2022 at 4:51 PM Chethan shetty @.***> wrote:

Ok I will try

Sent from my iPhone

On 15-Aug-2022, at 4:16 PM, Aliaksei-Ashukha @.***> wrote:



What version of org.jsoup do you use? Recomended version 1.11.3

— Reply to this email directly, view it on GitHub https://github.com/healenium/healenium-web/issues/195#issuecomment-1214878254, or unsubscribe https://github.com/notifications/unsubscribe-auth/AHOZTLKBVNZITSH5WO3JD53VZINZZANCNFSM55BLN5LA . You are receiving this because you were mentioned.Message ID: @.***>

Alex-Reif commented 2 years ago

Hi @mpchethan ,

First off, Healenium doesn't guarantee generate healed locator as xpath.

But there are some rules to increate chance receive xpath locator.

Source client locator:

Note: By default healenium generates css selector.

mpchethan commented 2 years ago

Thanks

Sent from my iPhone

On 24-Aug-2022, at 10:21 PM, Aliaksei-Ashukha @.***> wrote:

 Hi @mpchethan ,

First off, Healenium doesn't guarantee generate healed locator as xpath.

But there are some rules to increate chance receive xpath locator.

Source client locator:

be xpath as well. shouldn't contains more than one node (ancestor:: , /child, etc). starts from "//" character. Note: By default healenium generates css selector.

— Reply to this email directly, view it on GitHub, or unsubscribe. You are receiving this because you were mentioned.