Python Forum
Taking screenshots with http authentication with username and password from website - Printable Version

+- Python Forum (https://python-forum.io)
+-- Forum: Python Coding (https://python-forum.io/forum-7.html)
+--- Forum: Web Scraping & Web Development (https://python-forum.io/forum-13.html)
+--- Thread: Taking screenshots with http authentication with username and password from website (/thread-14430.html)



Taking screenshots with http authentication with username and password from website - onenessboy - Nov-29-2018

Dear All,

Is that possible to open a url in chrome and then login with credentials and then click on particular link there ,then taking screenshot of that page via shell script ? I need to open an website like XXXXX.XXXX.XXX.XX:1235 ..there will be two fields for login Username and Password once logged in I need to click a tab mention like bucket and then take screenshot of the screen
My OS : RHEL 7.5
Please give me some direction.

Please guide


RE: Taking screenshots with http authentication with username and password from website - micseydel - Nov-29-2018

You should take a look at Selenium.


RE: Taking screenshots with http authentication with username and password from website - nilamo - Nov-29-2018

If it's http authentication (https://developer.mozilla.org/en-US/docs/Web/HTTP/Authentication) then you can skip the form entirely, and just submit the credentials to whatever page you want a screenshot of.


RE: Taking screenshots with http authentication with username and password from website - onenessboy - Nov-30-2018

Hi,

I tried below selenium/python code with partial success

from selenium.common.exceptions import TimeoutException
from selenium.webdriver.common.keys import Keys

driver = webdriver.Chrome(executable_path=r'C:\Downloadsnew\chromedriver_win32\chromedriver.exe')
driver.maximize_window()
driver.implicitly_wait(20)
driver.get("http://xxxxx:1091/ui/index.html")

elem = driver.find_element_by_id("login_inp")
elem.send_keys("Administrator")
elem = driver.find_element_by_id("password2_inp")
elem.send_keys("password")
elem.send_keys(Keys.RETURN)
elem.click()
#elem=driver.find_element_by_xpath("//ul[@class='line']")
#elem1.find_element_by_xpath(".//a[@mn-tab='buckets']").click()
elem=driver.find_element_by_xpath("//div[@class='line' and text()='buckets']").click()
Its working till open page , fill username and password and login into page.
But, now I need to click on tab called buckets on screen, for which I am trying to locate the element by XPATH but its not working. Below code is not working.
#elem=driver.find_element_by_xpath("//ul[@class='line']")
#elem1.find_element_by_xpath(".//a[@mn-tab='buckets']").click()
elem=driver.find_element_by_xpath("//div[@class='line' and text()='buckets']").click()
[/python]

when I check inspect url

<div id="headerNav">
    <div class="contents">
      <ul mn-pluggable-ui-tabs="" mn-tab-bar-name="adminTab">
        <li mn-tab="overview" class="line currentNav" ui-sref-active="currentNav">
          <a ui-sref="app.admin.overview" href="#/overview">Overview</a>
        </li>
        <li mn-tab="servers" class="line" ui-sref-active="currentNav">
          <a class="switch_servers" ui-sref="app.admin.servers.list" href="#/servers/active">Server Nodes</a>
        </li>
        <li mn-tab="buckets" class="line" ui-sref-active="currentNav">
          <a class="switch_buckets" ui-sref="app.admin.buckets" href="#/buckets">Data Buckets</a>
        </li><li ng-show="rbac.cluster.admin.internal.all" class="line ng-scope" ui-sref-active="currentNav"><a ui-sref="app.admin.query.workbench" class="ng-binding" href="#/query/workbench">Query</a></li>
        
How to click that buckets ? any suggestions