Skip to content
This repository has been archived by the owner on Nov 24, 2018. It is now read-only.

Implement .click(x,y) to enable clicking at x, y coordinates #191

Open
AdamCanady opened this issue Aug 7, 2017 · 9 comments
Open

Implement .click(x,y) to enable clicking at x, y coordinates #191

AdamCanady opened this issue Aug 7, 2017 · 9 comments

Comments

@AdamCanady
Copy link

For applications where a click can be more specific than a single DOM element, does chromeless support clicks at x,y coordinates or could someone provide a pointer to how this could be implemented (happy to send a PR if you can help me get started)?

Thanks!

@adieuadieu adieuadieu changed the title Click at x,y coordinates? Implement .click(x,y) to enable clicking at x, y coordinates Aug 9, 2017
@adieuadieu
Copy link
Collaborator

Hi @AdamCanady — This isn't implemented yet. But we'd be happy to accept a PR! It might be a good first feature to implement for a first-time contributor. You could extend the .click() method to accept x,y coordinates. You can take a look at the .wait() method for how to support multiple function signatures, and then take a the .click() method itself on how to click at a specified location. Essentially, you just need to extend the existing .click() util function to skip the getClientRect() lookup if x,y coordinates are already provided. You might need to add a check to confirm that the x,y are within the document width/height within the local-runtime.js's .click implementation.

@AlexzanderFlores
Copy link

I would love this feature! Any news on if it is being worked on?

@JimLynchCodes
Copy link

Hey, I'd really need this feature as well! I'm going to try to do the whole clone + npm link thing and try to implement this. No promises, though! :)

@JimLynchCodes
Copy link

JimLynchCodes commented Dec 29, 2017

Btw I tried this, but it didn't work:

.evaluate(() => {
  document.elementFromPoint(200, 300).click();
})

@JimLynchCodes
Copy link

JimLynchCodes commented Jan 2, 2018

Hey @adieuadieu,
I am trying to following the directions in the README, but I don't think my test project is using the cloned version of chromeless. I cloned chromeless, ran npm install and _npm link, and then made a test project in which I run npm link chromeless. It seems all good, the output I get from npm link is:


> [email protected] install /Users/jameslynch/Git-Projects/chromeless/node_modules/fsevents
> node install

[fsevents] Success: "/Users/jameslynch/Git-Projects/chromeless/node_modules/fsevents/lib/binding/Release/node-v57-darwin-x64/fse.node" already installed
Pass --update-binary to reinstall or --build-from-source to recompile
added 18 packages, removed 11 packages and updated 300 packages in 43.028s
/Users/jameslynch/.nvm/versions/node/v8.9.1/lib/node_modules/chromeless -> /Users/jameslynch/Git-Projects/chromeless

and from npm link chromeless:

/Users/jameslynch/chromeless-test/node_modules/chromeless -> /Users/jameslynch/.nvm/versions/node/v8.9.1/lib/node_modules/chromeless -> /Users/jameslynch/Git-Projects/chromeless

However, when I run my test projectI get an error that it can't find chromeless:

chromeless-test ♘ node test.js 
module.js:538
    throw err;
    ^

Error: Cannot find module 'chromeless'
    at Function.Module._resolveFilename (module.js:536:15)
    at Function.Module._load (module.js:466:25)
    at Module.require (module.js:579:17)
    at require (internal/module.js:11:18)
    at Object.<anonymous> (/Users/jameslynch/chromeless-test/test.js:1:86)
    at Module._compile (module.js:635:30)
    at Object.Module._extensions..js (module.js:646:10)
    at Module.load (module.js:554:32)
    at tryModuleLoad (module.js:497:12)
    at Function.Module._load (module.js:489:3)

@adieuadieu
Copy link
Collaborator

@JimTheMan you likely need to run npm run build within your cloned chromeless repository to build the TypeScript code to Javascript.

@JimLynchCodes
Copy link

Hey thanks @adieuadie. I didn't realize I had top run npm run build again in the chromeless terminal each time a made a change. It's working now and I can see console.log's. :)

@JimLynchCodes JimLynchCodes mentioned this issue Jan 4, 2018
3 tasks
@JimLynchCodes
Copy link

I like the PR template. :)

My code isn't working, but I think it's close. I opened a PR so you guys could look at it and maybe let me know if I'm on the right track.

Also, the original function signature for click was export async function click(client: Client, selector: string, scale: number)

But can you explain a little what is client and where is that coming from? Thanks. :)

@skiloop
Copy link
Contributor

skiloop commented Apr 8, 2018

Instead of click absolute coordinates, I try to implement with relative position.
for example:
click(selector, x, y)
here i create a PR #426

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

No branches or pull requests

5 participants