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

Can not click Element by ClassName or linkText as same Facebook Driver #4

Closed
quyeticb opened this issue Oct 11, 2016 · 11 comments
Closed
Assignees

Comments

@quyeticb
Copy link

quyeticb commented Oct 11, 2016

hello, I want click by classname (many classname duplicate). How to click with classname $n
ex:

<a class="one" href="#">One</a>
<a class="one" href="#">Two</a>
......

I Want click link Two

And How do run PhantomJS via Sock 5 proxy?

@quyeticb
Copy link
Author

quyeticb commented Oct 11, 2016

OK, I solved run PhantomJS via socks 5. But Not solve the first problem. Need support!

@merlinthemagic
Copy link
Owner

Hi,

I would select the set of links in class "one" (a.one), then a sub selection using "nth-of-type(n)" like this:

$selector = "a.one:nth-of-type(2)";

You could use getElement() and make sure you have the right link. I also saw you wanted to click the link using mouseEventOnElement() before you edited the issue. In the Readme you will see that mouseEventOnElement() can only click elements that cover an area on the page. A vanilla hyperlink is just a link of text, to click use the clickElement() method instead.

@merlinthemagic merlinthemagic self-assigned this Oct 11, 2016
@quyeticb
Copy link
Author

quyeticb commented Oct 11, 2016

Thanks for fast support. I will check it again.
Now, I have a problem with the function sendKeyPresses
If string to send is utf-8 is always error (timeout error).
You can check and review it.

And If error, these folder in WorkDirectory do not delete, may be error for next PhantomJS instances

@merlinthemagic
Copy link
Owner

merlinthemagic commented Oct 11, 2016

What's your OS, version and architecture?

Can you send me the string that fails? The fact that the process does not exit is quite odd. There is only two scenarios I can think of that would cause the process to live beyond the lifetime of the PHP script. That would be if the command you execute is the very first one OR if you are using a very old version of MTS. When did you download MTS and are you using master or a specific release?

@quyeticb
Copy link
Author

quyeticb commented Oct 11, 2016

Oh, one moment, I create many instances while do not terminate it before.
But $windowObj->close() still not working.
This is error:

PHP Fatal error: Uncaught Exception: MTS\Common\Devices\Browsers\PhantomJS::browserCloseWindow>> Got result code: 0, EMsg: Failed to close window. Error: ReferenceError: Can't find variable: myArray, ECode: 0 in /MTS/Common/Devices/Browsers/PhantomJS.php:111
Stack trace:
#0 /MTS/Common/Devices/Browsers/Base.php(86): MTS\Common\Devices\Browsers\PhantomJS->browserCloseWindow(Object(MTS\Common\Devices\Browsers\Window))
#1 /MTS/Common/Devices/Browsers/Window.php(79): MTS\Common\Devices\Browsers\Base->closeWindow(Object(MTS\Common\Devices\Browsers\Window))
#2 /test.php(185): MTS\Common\Devices\Browsers\Window->close()
#3 {main}
thrown in /MTS/Common/Devices/Browsers/PhantomJS.php on line 111

@merlinthemagic
Copy link
Owner

Are you using the current version of master? If not how old is it?

Since you customized MTS do you have a repository where I can look at the code?

I am puzzled because $windowObj->close() does not invoke terminate of the entire browserObj just that window.

@quyeticb
Copy link
Author

I'm using latest MTS release.

@merlinthemagic
Copy link
Owner

The reason I would like to see the code is that the Exception trace shows:

Can't find variable: myArray, ECode: 0 in /MTS/Common/Devices/Browsers/PhantomJS.php:111

That variable is not defined in the stock MTS package. It's hard to help you without knowing how you customized the package.

@quyeticb
Copy link
Author

quyeticb commented Oct 11, 2016

Thank you, I will track it again, but I do not modifie PhantomJS.php.
PS: I Like your source code. It is useful, instead of having to use webdriver. You can review the sendKeyPresses with an unicode string. Ex: sendKeyPresses('Côte dIvoire')

@merlinthemagic
Copy link
Owner

The exception is relayed from the .js executed by phantomJS. It's not a PHP exception originally.

@quyeticb
Copy link
Author

Yes, I fixed it! Thanks!

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

2 participants