Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

error: 'no such element' #1015

Open
VijayanRamachandran opened this issue Jul 27, 2021 · 2 comments
Open

error: 'no such element' #1015

VijayanRamachandran opened this issue Jul 27, 2021 · 2 comments

Comments

@VijayanRamachandran
Copy link

Hi,

Currently i am facing an issue with Spectron in combination with Mocha.

When i try to get element text using spectron in test case i am facing error "no such element".

Sample.html

image

main.js

image

package.json

"devDependencies": {
"electron": "^13.1.6",
"mocha": "^9.0.2",
"spectron": "^15.0.0"
}

SampleTest.js

image

Error

image

Can you help me regarding this ?

Is it problem in my implementation ?

@xupea
Copy link
Contributor

xupea commented Jul 28, 2021

you may misunderstand element id and dom id, and to get the text content from a DOM-element, please refer to getText

@oscartbeaumont
Copy link

To clarify @xupea comment, I have put a code sample below.

Use await (await app.client.$("#test")).getText() where app refers to the Spectron Application and #test refers to the element in the DOM with id test (<h1 id="test">Hello World</h1>).

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants