Invoke click and page submission

2

I will not post code on the question because I do not know the beginning. I have an HTML page and I want to know if it is possible, with PHP to invoke click action, etc., on selectors for example .classe#id .

Example:

<body>
    <button id='go'>Meu botão 1</button>
    <button id='ex'>Meu botão 2</button>
</body>

In an external PHP it is possible to request the button#go or button#ex ? If so, how?

    
asked by anonymous 15.02.2017 / 04:50

2 answers

0

Searching and finding more terms for the search, I find libraries that do this, as is the case of Goutte , in addition the SimpleTest has a similar tool, etc., it is usually turned to functional testing / system testing.

    
15.02.2017 / 15:56
1

PHP does not do this, but it is possible to make PHP call who does - JavaScript with JQuery.

PHP runs on the server, the click happens on the client - in the browser.

What you can do is PHP generate JavaScript code that makes the click event.

<script>
    <?php if ($habilita_clique_go) { ?>
        $('#go').click();
    <?php } ?>

    <?php if ($habilita_clique_ex) { ?>
        $('#ex').click();
    <?php } ?>
</script>
    
15.02.2017 / 12:53