I am using django 1.10, selenium 3.4 and python 3.6.
My PC is used to test if my code is accurate. Using Chrome webdriver
The production service is on Amazon EC2 Ubuntu instance. Using Chrome webdriver as well but without display like below.
display = Display(visible=0, size=(1024, 768))
display.start()
I was using selenium to find a certain information that resides in the html like below code.
<div id="myid">
<table>
<tbody>
<tr>...</tr>
<tr>
<td>...</td>
<td ...>
<div ...>
<div ...>
<table ...>
<tbody>
<tr>...</tr>
<tr ...>
<td ...></td>
<td ...></td>
<td ...></td>
<td ...></td>
<td ...></td>
<td ...></td>
<td ...>This is what I searching</td>
<td ...></td>
<td ...></td>
..........
Sadly, there's not much id or unique class that I can use on searching.
So, I'm using xpath as this line.
driver.find_element_by_xpath("//div[@id='treegrid_QUICKSEARCH_TABLE']/table/tbody/tr[2]/td[2]/div/div[1]/table/tbody/tr[2]/td[7]").text
I can find the element I want on my PC with browser.
But not on my EC2 instance without display.
When I check the upper tag of it.
driver.find_element_by_xpath("//div[@id='treegrid_QUICKSEARCH_TABLE']/table/tbody/tr[2]/td[2]/div/div[1]/table/tbody/tr[2]").text
I found that selenium is indeed not getting that text I'm searching.
I even tried increasing the size of Display to (1920,1920)
But selenium is only not getting that text.
Once again, the code works just fine on my PC with browser.
Can someone tell me what's the problem?