invalid selector: The result of the xpath expression. It should be an elementjQuery selector regular expressionscontent from divs into textareaHow can I get selenium/cucumber to interact with a “hidden” link that is now in a lightbox/colorbox?What do test automation frameworks provide that my approach of scripting with Selenium Webdriver doesn't?How to find selector for a random ID, XPATH & CSSpath, I'm testing a CMS tool with Selenium c#DOM traversing using jQueryhow to merge duplicated items in javascript array?selenium javascript webdriver - unable to locate dynamic elementXPath returns wrong elementHow to get parent element text and remove child element text selenium c#?
Multi tool use
What exactly is a marshrutka (маршрутка)?
Linear Programming with additional "if-then"/"Default to zero" constraints?
Why isn't `typename` required for a base class that is a nested type?
Have there been any countries that voted themselves out of existence?
Why does Coq include let-expressions in its core language
Is this WWI movie scene realistic?
When was the earliest opportunity the Voyager crew had to return to the Alpha quadrant?
Has SHA256 been broken by Treadwell Stanton DuPont?
Is there a real-world mythological counterpart to WoW's "kill your gods for power" theme?
Evidence that matrix multiplication cannot be done in O(n^2 poly(log(n))) time
How do I determine what is "magic" and "bearing magic" for Detect Magic?
What was the relationship between Einstein and Minkowski?
Uncovering the Accelerated Dragon opening
Writing a love interest for my hero
How can I locate a missing person abroad?
Will replacing a fake visa with a different fake visa cause me problems when applying for a legal study permit?
Mean π: Archimedes vs. Gauss - π computation through generalized means
Gas pipes - why does gas burn "outwards?"
Is it appropriate for a professor to require students to sign a non-disclosure agreement before being taught?
Do Milankovitch Cycles fully explain climate change?
Is there any way to land a rover on the Moon without using any thrusters?
Does a gnoll speak both Gnoll and Abyssal, or is Gnoll a dialect of Abyssal?
How can I fix a framing mistake so I can drywall?
A shy person in a queue
invalid selector: The result of the xpath expression. It should be an element
jQuery selector regular expressionscontent from divs into textareaHow can I get selenium/cucumber to interact with a “hidden” link that is now in a lightbox/colorbox?What do test automation frameworks provide that my approach of scripting with Selenium Webdriver doesn't?How to find selector for a random ID, XPATH & CSSpath, I'm testing a CMS tool with Selenium c#DOM traversing using jQueryhow to merge duplicated items in javascript array?selenium javascript webdriver - unable to locate dynamic elementXPath returns wrong elementHow to get parent element text and remove child element text selenium c#?
.everyoneloves__top-leaderboard:empty,.everyoneloves__mid-leaderboard:empty,.everyoneloves__bot-mid-leaderboard:empty margin-bottom:0;
I am writing automation test in selenium with javascript steps. In the test I want to check if TEXT3 equals TEXT3
HTML code of the website:
<div _ngcontent-c35="" class="content">
<p>
TEXT1
<u>
<strong>TEXT2</strong>
</u>
TEXT3
</p>
</div>
Javascript code:
this.Then(/^also "([^"]*)" as loanPurposeInfoDialogLabel03 is displayed$/, function (fieldValue, next)
var fieldText = this.driver.findElement(By.xpath("//div[@class='content']/p/text()[2]"));
fieldText.getText().then(getFieldValue =>
assert.equal(getFieldValue, fieldValue, next, 'Expected value of loanPurposeInfoDialogLabel03 (Text) to be: ' + fieldValue);
, next);
);
Javascript code does not work in case I use /text() in XPATH
//div[@class='content']/p/text()[2]
I get error:
InvalidSelectorError: invalid selector: The result of the xpath expression "//div[@class='content']/p/text()[2]" is: [object Text]. It should be an element.
javascript cucumber gherkin
add a comment
|
I am writing automation test in selenium with javascript steps. In the test I want to check if TEXT3 equals TEXT3
HTML code of the website:
<div _ngcontent-c35="" class="content">
<p>
TEXT1
<u>
<strong>TEXT2</strong>
</u>
TEXT3
</p>
</div>
Javascript code:
this.Then(/^also "([^"]*)" as loanPurposeInfoDialogLabel03 is displayed$/, function (fieldValue, next)
var fieldText = this.driver.findElement(By.xpath("//div[@class='content']/p/text()[2]"));
fieldText.getText().then(getFieldValue =>
assert.equal(getFieldValue, fieldValue, next, 'Expected value of loanPurposeInfoDialogLabel03 (Text) to be: ' + fieldValue);
, next);
);
Javascript code does not work in case I use /text() in XPATH
//div[@class='content']/p/text()[2]
I get error:
InvalidSelectorError: invalid selector: The result of the xpath expression "//div[@class='content']/p/text()[2]" is: [object Text]. It should be an element.
javascript cucumber gherkin
add a comment
|
I am writing automation test in selenium with javascript steps. In the test I want to check if TEXT3 equals TEXT3
HTML code of the website:
<div _ngcontent-c35="" class="content">
<p>
TEXT1
<u>
<strong>TEXT2</strong>
</u>
TEXT3
</p>
</div>
Javascript code:
this.Then(/^also "([^"]*)" as loanPurposeInfoDialogLabel03 is displayed$/, function (fieldValue, next)
var fieldText = this.driver.findElement(By.xpath("//div[@class='content']/p/text()[2]"));
fieldText.getText().then(getFieldValue =>
assert.equal(getFieldValue, fieldValue, next, 'Expected value of loanPurposeInfoDialogLabel03 (Text) to be: ' + fieldValue);
, next);
);
Javascript code does not work in case I use /text() in XPATH
//div[@class='content']/p/text()[2]
I get error:
InvalidSelectorError: invalid selector: The result of the xpath expression "//div[@class='content']/p/text()[2]" is: [object Text]. It should be an element.
javascript cucumber gherkin
I am writing automation test in selenium with javascript steps. In the test I want to check if TEXT3 equals TEXT3
HTML code of the website:
<div _ngcontent-c35="" class="content">
<p>
TEXT1
<u>
<strong>TEXT2</strong>
</u>
TEXT3
</p>
</div>
Javascript code:
this.Then(/^also "([^"]*)" as loanPurposeInfoDialogLabel03 is displayed$/, function (fieldValue, next)
var fieldText = this.driver.findElement(By.xpath("//div[@class='content']/p/text()[2]"));
fieldText.getText().then(getFieldValue =>
assert.equal(getFieldValue, fieldValue, next, 'Expected value of loanPurposeInfoDialogLabel03 (Text) to be: ' + fieldValue);
, next);
);
Javascript code does not work in case I use /text() in XPATH
//div[@class='content']/p/text()[2]
I get error:
InvalidSelectorError: invalid selector: The result of the xpath expression "//div[@class='content']/p/text()[2]" is: [object Text]. It should be an element.
javascript cucumber gherkin
javascript cucumber gherkin
asked Mar 28 at 9:11
Ondrej StrakaOndrej Straka
62 bronze badges
62 bronze badges
add a comment
|
add a comment
|
2 Answers
2
active
oldest
votes
Because you are giving text()
function inside of xpath, please try following code :
var fieldText = this.driver.findElement(By.xpath("//div[@class='content']/p/text[2]"));
Sorry, but it did not work.code NoSuchElementError: no such element: Unable to locate element: "method":"xpath","selector":"//div[@class='content']/p/text[1]" (Session info: chrome=72.0.3626.109) (Driver info: chromedriver=2.45.615291 (ec3682e3c9061c10f26ea9e5cdcf3c53f3f74387),platform=Windows NT 10.0.17134 x86_64) (WARNING: The server did not provide any stacktrace information)
And if I type xpath above into console of google chrome it does not found text xpath whitout ()
– Ondrej Straka
Mar 28 at 17:31
What happens when you just use "//div[@class='content']/p" this. it can get all text inside.
– Selçuk Ayhan
Mar 29 at 6:35
If I use "//div[@class='content']/p" value is TEXT1 TEXT2 TEXT3 so it is not necesery to create step for TEXT3 Thanks :)
– Ondrej Straka
Apr 2 at 6:36
So that means there is no 3 elements, there is only one element with styling.
– Selçuk Ayhan
Apr 2 at 7:04
add a comment
|
If I use xpath
"//div[@class='content']/p"
value is TEXT1 TEXT2 TEXT3, so it is not necesery to create step for TEXT3
Thanks to Selçuk Ayhan :)
add a comment
|
Your Answer
StackExchange.ifUsing("editor", function ()
StackExchange.using("externalEditor", function ()
StackExchange.using("snippets", function ()
StackExchange.snippets.init();
);
);
, "code-snippets");
StackExchange.ready(function()
var channelOptions =
tags: "".split(" "),
id: "1"
;
initTagRenderer("".split(" "), "".split(" "), channelOptions);
StackExchange.using("externalEditor", function()
// Have to fire editor after snippets, if snippets enabled
if (StackExchange.settings.snippets.snippetsEnabled)
StackExchange.using("snippets", function()
createEditor();
);
else
createEditor();
);
function createEditor()
StackExchange.prepareEditor(
heartbeatType: 'answer',
autoActivateHeartbeat: false,
convertImagesToLinks: true,
noModals: true,
showLowRepImageUploadWarning: true,
reputationToPostImages: 10,
bindNavPrevention: true,
postfix: "",
imageUploader:
brandingHtml: "Powered by u003ca class="icon-imgur-white" href="https://imgur.com/"u003eu003c/au003e",
contentPolicyHtml: "User contributions licensed under u003ca href="https://creativecommons.org/licenses/by-sa/4.0/"u003ecc by-sa 4.0 with attribution requiredu003c/au003e u003ca href="https://stackoverflow.com/legal/content-policy"u003e(content policy)u003c/au003e",
allowUrls: true
,
onDemand: true,
discardSelector: ".discard-answer"
,immediatelyShowMarkdownHelp:true
);
);
Sign up or log in
StackExchange.ready(function ()
StackExchange.helpers.onClickDraftSave('#login-link');
);
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
StackExchange.ready(
function ()
StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f55393812%2finvalid-selector-the-result-of-the-xpath-expression-it-should-be-an-element%23new-answer', 'question_page');
);
Post as a guest
Required, but never shown
2 Answers
2
active
oldest
votes
2 Answers
2
active
oldest
votes
active
oldest
votes
active
oldest
votes
Because you are giving text()
function inside of xpath, please try following code :
var fieldText = this.driver.findElement(By.xpath("//div[@class='content']/p/text[2]"));
Sorry, but it did not work.code NoSuchElementError: no such element: Unable to locate element: "method":"xpath","selector":"//div[@class='content']/p/text[1]" (Session info: chrome=72.0.3626.109) (Driver info: chromedriver=2.45.615291 (ec3682e3c9061c10f26ea9e5cdcf3c53f3f74387),platform=Windows NT 10.0.17134 x86_64) (WARNING: The server did not provide any stacktrace information)
And if I type xpath above into console of google chrome it does not found text xpath whitout ()
– Ondrej Straka
Mar 28 at 17:31
What happens when you just use "//div[@class='content']/p" this. it can get all text inside.
– Selçuk Ayhan
Mar 29 at 6:35
If I use "//div[@class='content']/p" value is TEXT1 TEXT2 TEXT3 so it is not necesery to create step for TEXT3 Thanks :)
– Ondrej Straka
Apr 2 at 6:36
So that means there is no 3 elements, there is only one element with styling.
– Selçuk Ayhan
Apr 2 at 7:04
add a comment
|
Because you are giving text()
function inside of xpath, please try following code :
var fieldText = this.driver.findElement(By.xpath("//div[@class='content']/p/text[2]"));
Sorry, but it did not work.code NoSuchElementError: no such element: Unable to locate element: "method":"xpath","selector":"//div[@class='content']/p/text[1]" (Session info: chrome=72.0.3626.109) (Driver info: chromedriver=2.45.615291 (ec3682e3c9061c10f26ea9e5cdcf3c53f3f74387),platform=Windows NT 10.0.17134 x86_64) (WARNING: The server did not provide any stacktrace information)
And if I type xpath above into console of google chrome it does not found text xpath whitout ()
– Ondrej Straka
Mar 28 at 17:31
What happens when you just use "//div[@class='content']/p" this. it can get all text inside.
– Selçuk Ayhan
Mar 29 at 6:35
If I use "//div[@class='content']/p" value is TEXT1 TEXT2 TEXT3 so it is not necesery to create step for TEXT3 Thanks :)
– Ondrej Straka
Apr 2 at 6:36
So that means there is no 3 elements, there is only one element with styling.
– Selçuk Ayhan
Apr 2 at 7:04
add a comment
|
Because you are giving text()
function inside of xpath, please try following code :
var fieldText = this.driver.findElement(By.xpath("//div[@class='content']/p/text[2]"));
Because you are giving text()
function inside of xpath, please try following code :
var fieldText = this.driver.findElement(By.xpath("//div[@class='content']/p/text[2]"));
answered Mar 28 at 15:46
Selçuk AyhanSelçuk Ayhan
8878 silver badges17 bronze badges
8878 silver badges17 bronze badges
Sorry, but it did not work.code NoSuchElementError: no such element: Unable to locate element: "method":"xpath","selector":"//div[@class='content']/p/text[1]" (Session info: chrome=72.0.3626.109) (Driver info: chromedriver=2.45.615291 (ec3682e3c9061c10f26ea9e5cdcf3c53f3f74387),platform=Windows NT 10.0.17134 x86_64) (WARNING: The server did not provide any stacktrace information)
And if I type xpath above into console of google chrome it does not found text xpath whitout ()
– Ondrej Straka
Mar 28 at 17:31
What happens when you just use "//div[@class='content']/p" this. it can get all text inside.
– Selçuk Ayhan
Mar 29 at 6:35
If I use "//div[@class='content']/p" value is TEXT1 TEXT2 TEXT3 so it is not necesery to create step for TEXT3 Thanks :)
– Ondrej Straka
Apr 2 at 6:36
So that means there is no 3 elements, there is only one element with styling.
– Selçuk Ayhan
Apr 2 at 7:04
add a comment
|
Sorry, but it did not work.code NoSuchElementError: no such element: Unable to locate element: "method":"xpath","selector":"//div[@class='content']/p/text[1]" (Session info: chrome=72.0.3626.109) (Driver info: chromedriver=2.45.615291 (ec3682e3c9061c10f26ea9e5cdcf3c53f3f74387),platform=Windows NT 10.0.17134 x86_64) (WARNING: The server did not provide any stacktrace information)
And if I type xpath above into console of google chrome it does not found text xpath whitout ()
– Ondrej Straka
Mar 28 at 17:31
What happens when you just use "//div[@class='content']/p" this. it can get all text inside.
– Selçuk Ayhan
Mar 29 at 6:35
If I use "//div[@class='content']/p" value is TEXT1 TEXT2 TEXT3 so it is not necesery to create step for TEXT3 Thanks :)
– Ondrej Straka
Apr 2 at 6:36
So that means there is no 3 elements, there is only one element with styling.
– Selçuk Ayhan
Apr 2 at 7:04
Sorry, but it did not work.
code NoSuchElementError: no such element: Unable to locate element: "method":"xpath","selector":"//div[@class='content']/p/text[1]" (Session info: chrome=72.0.3626.109) (Driver info: chromedriver=2.45.615291 (ec3682e3c9061c10f26ea9e5cdcf3c53f3f74387),platform=Windows NT 10.0.17134 x86_64) (WARNING: The server did not provide any stacktrace information)
And if I type xpath above into console of google chrome it does not found text xpath whitout ()– Ondrej Straka
Mar 28 at 17:31
Sorry, but it did not work.
code NoSuchElementError: no such element: Unable to locate element: "method":"xpath","selector":"//div[@class='content']/p/text[1]" (Session info: chrome=72.0.3626.109) (Driver info: chromedriver=2.45.615291 (ec3682e3c9061c10f26ea9e5cdcf3c53f3f74387),platform=Windows NT 10.0.17134 x86_64) (WARNING: The server did not provide any stacktrace information)
And if I type xpath above into console of google chrome it does not found text xpath whitout ()– Ondrej Straka
Mar 28 at 17:31
What happens when you just use "//div[@class='content']/p" this. it can get all text inside.
– Selçuk Ayhan
Mar 29 at 6:35
What happens when you just use "//div[@class='content']/p" this. it can get all text inside.
– Selçuk Ayhan
Mar 29 at 6:35
If I use "//div[@class='content']/p" value is TEXT1 TEXT2 TEXT3 so it is not necesery to create step for TEXT3 Thanks :)
– Ondrej Straka
Apr 2 at 6:36
If I use "//div[@class='content']/p" value is TEXT1 TEXT2 TEXT3 so it is not necesery to create step for TEXT3 Thanks :)
– Ondrej Straka
Apr 2 at 6:36
So that means there is no 3 elements, there is only one element with styling.
– Selçuk Ayhan
Apr 2 at 7:04
So that means there is no 3 elements, there is only one element with styling.
– Selçuk Ayhan
Apr 2 at 7:04
add a comment
|
If I use xpath
"//div[@class='content']/p"
value is TEXT1 TEXT2 TEXT3, so it is not necesery to create step for TEXT3
Thanks to Selçuk Ayhan :)
add a comment
|
If I use xpath
"//div[@class='content']/p"
value is TEXT1 TEXT2 TEXT3, so it is not necesery to create step for TEXT3
Thanks to Selçuk Ayhan :)
add a comment
|
If I use xpath
"//div[@class='content']/p"
value is TEXT1 TEXT2 TEXT3, so it is not necesery to create step for TEXT3
Thanks to Selçuk Ayhan :)
If I use xpath
"//div[@class='content']/p"
value is TEXT1 TEXT2 TEXT3, so it is not necesery to create step for TEXT3
Thanks to Selçuk Ayhan :)
answered Apr 2 at 6:46
Ondrej StrakaOndrej Straka
62 bronze badges
62 bronze badges
add a comment
|
add a comment
|
Thanks for contributing an answer to Stack Overflow!
- Please be sure to answer the question. Provide details and share your research!
But avoid …
- Asking for help, clarification, or responding to other answers.
- Making statements based on opinion; back them up with references or personal experience.
To learn more, see our tips on writing great answers.
Sign up or log in
StackExchange.ready(function ()
StackExchange.helpers.onClickDraftSave('#login-link');
);
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
StackExchange.ready(
function ()
StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f55393812%2finvalid-selector-the-result-of-the-xpath-expression-it-should-be-an-element%23new-answer', 'question_page');
);
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function ()
StackExchange.helpers.onClickDraftSave('#login-link');
);
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function ()
StackExchange.helpers.onClickDraftSave('#login-link');
);
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function ()
StackExchange.helpers.onClickDraftSave('#login-link');
);
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
WCdqgD sRK6 x,Kq 2WQ,chjOcSxLd,ezMZgLBHi7WD2Lqbv4,vpgPx3QwXTQ20v RcVNUr9Vu TXUg E YjYKyx6NJcx 2zZXo