Python Forum

Full Version: Selenium locating an element.
You're currently viewing a stripped down version of our content. View the full version with proper formatting.
Hi guys !
So I have an question about Selenium, I want to locate the userName tag . By inspecting the site I found this whole class :
" <span class="b-link js-profile-header-name js-hp-view-element" data-element-name="userName"></span> " .

Thats pretty much it but it is in "profile-header__user" class and thats in profile-header__info and that is in profile-header__inner and so on ....There are many div classes and I guess thats the issue.
My code cant find the button ( which isnt a button but when you hover on it you can click on it) ,and I want Selenium to click on it. Ive try multiple combination.

Can`t search for text because always when the site refreshes ,the name will change.
Can you guys give me a hint or maybe an article to read or something .
Im still learning so please dont get upset :) !

Have a nice day !
JokerTux.
Can you post link to site?,it's hard to test this stuff without doing it live.

I have setup so i can do some testing local.
The span tag usually get some date,here i put in username.
<span class="b-link js-profile-header-name js-hp-view-element" data-element-name="userName">username</span>
in my test code.
span = browser.find_elements_by_class_name('b-link')
E:\div_code\scrape
λ ptpython -i local_chrome.py

>>> span
[<selenium.webdriver.remote.webelement.WebElement (session="f09352246e80ff04e3ce05999703987c", element="e479c4a5-40e0-4636-915d-ff1ea297ac8f")>]

>>> span[0].text
'username'
This may not work on the web-site,there are lot of different setup eg a lot diffent JS framework and technique used.
The web code is really mess under the hood Doh
Hi !
Thank you for your quick replay , so the site is badoo.com :D .
I was writing a script that looks into the personal details and checks if this person has kids for example.
After getting this information the next step is to reject or click on the love button ,but I`m not that far yet.
The main issue is it wont click on the name which after clicking on it gives more details.
Its not that important , its just a project for fun ;).
(Dec-27-2019, 05:25 PM)JokerTux Wrote: [ -> ]Thank you for your quick replay , so the site is badoo.com :D .
I am not gone register to a dating site to test this out Wink