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

[BUG] Element is not found for click #2037

Closed
jperl opened this issue Apr 29, 2020 · 4 comments
Closed

[BUG] Element is not found for click #2037

jperl opened this issue Apr 29, 2020 · 4 comments

Comments

@jperl
Copy link
Contributor

jperl commented Apr 29, 2020

Context:

  • Playwright Version: 0.15.0
  • Operating System: Mac
  • Node version: [e.g. 10.12, 10.14]
  • Browser: Chromium

Code Snippet

const playwright = require("playwright");

(async () => {
  const browser = await playwright.chromium.launch({ headless: false });
  const page = await browser.newPage();
  await page.goto("https://appannie.com/");
  await page.click("text=Products");
  await page.click("css=div:nth-of-type(6) >> text=Connect");
  await page.click("text=Connect your apps for free");
})();

Screen Shot 2020-04-29 at 2 29 45 PM

Describe the bug

The selector is not clicked on. When you manually hover over the menu the click proceeds.

TimeoutError: waiting for selector "css=div:nth-of-type(6) >> text=Connect" failed: timeout exceeded

@pavelfeldman
Copy link
Member

I guess css=div:nth-of-type(6) points to different places depending on whether you hover or not. Looks like the page could make a step towards tesability and provide stable id or classes :/

@jperl
Copy link
Contributor Author

jperl commented Apr 29, 2020

Ok I thought I saw somewhere in the code that playwright click tries to force a hover, but I was probably mistaken.

@arjunattam
Copy link
Contributor

Just in case it helps, using the href attribute worked for me

const playwright = require("playwright");

(async () => {
  const browser = await playwright.chromium.launch({ headless: false });
  const page = await browser.newPage();
  await page.goto("https://appannie.com/");
  await page.click("text=Products");
  await page.click("a[href=\"/en/product/connect/\"]");
  await page.click("text=Connect your apps for free");
})();

@jperl
Copy link
Contributor Author

jperl commented Apr 29, 2020

Thank you 🙏

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