willem

willem

Hi everyone. I’ve come across html code containing “phx-click” and a google search has lead me to phoenix and this forum. I hope I’m at the right place and that someone here can help me.

First off, I don’t really know Javascript, so phoenix and elixir is completely foreign to me, I don’t even know how the two relate to each other.

I’m trying to automate changing a setting on a Web app for a device in my home using phantomjs. Note I can access the http webpage of the device, but do not have any control over the html or javascript code itself. Right now the obstacle I’m trying to pass is clicking on the following link:

<a href="#" phx-click="edit_settings" phx-target="1">edit</a>

Code in my phantomjs script is:

SetTimeout(function() {
    console.log("");
    console.log("### STEP 3: Click on edit link");
    page.evaluate(function() {
        var ev = document.createEvent("MouseEvents");
        ev.initEvent("click", true, true);
        document.querySelector("#settings > div > form > div > div.full > h3 > span > a").dispatchEvent(ev);
    });
}, 6000);

I’ve also tried replacing dispatchEvent(ev) with click().

As far as I can see the correct element is selected, but the page doesn’t switch to edit mode, i.e. doesn’t respond to the click. I’ve tried tracing what happens when the link is clicked in chrome Web tools, but then too the page doesn’t respond to the click. Any suggestions on how I can get the page to switch to edit mode.

From my searches online I’ve gathered that if a link is coded with the normal on-click attribute then the phoenix stuff don’t respond or work with that code and the opposite seem to be true as well. With the link having the phx-click attribute the normal click methods and events doesn’t seem to effect the link.

Ultimately I would like phantomjs to click above mentioned edit link, change a value in a drop down box and click the save button. I believe if I can get past the first edit link obstacle I should be able to manage the rest. I’m hoping that there is perhaps something like “element.phxclick(‘edit-settings’)” that can be used to trigger the click on that edit link. Any help or suggestions would be much appreciated. Even if the solution doesn’t involve using phantomjs. As long as it is a command line command I can enter to change the setting so that I can use that in another script again. Maybe one don’t even have to simulate the click and one can somehow just send the necessary data directly to the device using a http post, but I can’t figure out how the data is sent to the device either.

Showing Posts 1 to 1

kokolegorille

kokolegorille

Hello and welcome,

Elixir and Javascript are not related, they are different language.

Phoenix is a web framework and might use Javascript.

But all phx-click are related to Liveview, which is an attempt to avoid using JS. And You need to have a Phoenix server to use it.

And phantomjs… probably You use it as an http client, to control your device.

It’s possible to manage your device from an http client, but adding Phoenix to do this is not the easiest path :slight_smile:

— All posts loaded —

Where Next? Top

Trending in Questions Top

stjefim
Hello! Suppose you are building workflow (order / task / payment) processing system with the following requirements: Each workflow con...
New
water
I’m aware of 2 such projects, are there others? git: GitHub - team-alembic/realworld: A fullstack Phoenix LiveView application with back...
New
itzmidinesh
Hi all, I’m working on a Phoenix project where I need to make external HTTP requests and I’m trying to choose between Req and HTTPoison....
New
peck
Hi everyone. My team and I have been working on a fairly modest app based around video streaming and chat, but we’ve landed a customer t...
New
leoschweizer
Hi, we run different LLM models across a cluster, with each node loading a configurable subset. Model-specific queues let nodes consume ...
New
csmr
Hi all, I’m new here and would like to hear peoples views on my Elixir/Phoenix based game-engine! :smiley: Mutonex gamedesign was finish...
New
perzanko
Do we have maintainer of absinthe-graphql/dataloader here? We have a PR that we’d like to merge to the library. Relatively small additive...
New

Other Trending Topics Top

dominicletz
Hey there, I haven’t seen a list of useful Elixir specific skills for the popular AI tools yet so I’m starting one here with my first. ...
New
mudasobwa
I fully migrated to my own harness from Anthropic/Gemini and I think it’s time to share it. Welcome DSH, the DeepSeek Harness, fully writ...
New
KristerV
Hey. Is there anyone here who creates agents in their apps? Not talking about using agents, but creating them. I’m finding it pretty diff...
New
jimsynz
Beam Bots (or just BB for short) is a framework for building fault-tolerant robotics applications in Elixir using familiar OTP patterns. ...
New
webofbits
With AI doing more of the implementation work, I’ve been wondering how much coding I should deliberately keep doing myself. My main conc...
#ai
New
OndrejValenta
(I just needed to vent somewhere and LinkedIn is full of hope, or hype, I’m not sure which exactly) AI dream has many faces, but general...
New

We're in Beta

About us Mission Statement

Options

Thread Display Mode




Thread Preview

Skip Thread Previews