can't get element not frame issue, and the style is display block.

51 views
Skip to first unread message

Zhe Lee

unread,
Oct 20, 2017, 10:32:03 AM10/20/17
to Selenium Users
On this web,  I can't get elements under this tab. Why is that? 


the code I use is like this: 

print(driver_sell.find_element_by_css_selector('#js-dota2-sale > tbody > tr:nth-child(1) > td:nth-child(2)').text)
print(driver_sell.find_element_by_css_selector('#js-tbody-data > tr:nth-child(1) > td:nth-child(3) > span').text)
print(driver_sell.find_element_by_css_selector('#js-dota2-sale > tbody > tr:nth-child(1) > td:nth-child(1) > a > span').text)
print(driver_sell.find_element_by_css_selector('#js-dota2-sale > tbody > tr:nth-child(2) > td:nth-child(3)').text)





Zhe Lee

unread,
Oct 20, 2017, 9:12:03 PM10/20/17
to Selenium Users
at first the element is invisible then I click on the 求购 button and get the element but is empty, if I click on that, error shows that the element is invisible. 

Zhe Lee

unread,
Oct 20, 2017, 11:05:23 PM10/20/17
to Selenium Users
may the web do some trick that forbidden to get some element? 


On Friday, October 20, 2017 at 10:32:03 PM UTC+8, Zhe Lee wrote:

David

unread,
Oct 23, 2017, 3:57:41 PM10/23/17
to Selenium Users
1st, can you "locate" the element using Firebug/FirePath/Firefinder and similar browser tools? That's to make sure you have the right element identifier.

Next, you might want to try and see if you can access & manipulate the element via javascript via the DOM in the browser developer/error console.

e.g. run
document.querySelector("#js-tbody-data > tr:nth-child(1) > td:nth-child(3) > span").innerHTML;

then see if you get any output in the console or if some error is printed

and can also try something like

document.querySelector("#js-tbody-data > tr:nth-child(1) > td:nth-child(3) > span").id = "adding my custom ID to test";

then run previous query (or similar query but query for .outerHTML) to see that the newly added ID is in the HTML.

These will tell you whether you can access the elements at all or not. And you would then want to inspect the properties of the element to see if it has anything that would make Selenium consider it "invisible" or not editable/workable with, e.g. "display: block;" CSS property for an element.

And if these queries work, they are workarounds to read or edit the element's state via javascript(executor via Selenium) if you are having issues with Selenium native methods.

Zhe Lee

unread,
Oct 29, 2017, 10:58:06 PM10/29/17
to Selenium Users
Really appreciate your reply, 

According to your advise I use console to check the value which I want to query. And I get the empty result, it works fine when I query elements on the '出售' tab, but get empty value in the "求购" tab. So strange. 

Zhe Lee

unread,
Oct 29, 2017, 11:00:18 PM10/29/17
to Selenium Users


As you see on the picture the 'document.querySelector("#js-dota2-sale > tbody > tr:nth-child(1) > td:nth-child(2)").innerHTML' get the empty value according to the output of the console. 


On Tuesday, October 24, 2017 at 3:57:41 AM UTC+8, David wrote:
Reply all
Reply to author
Forward
0 new messages