php - Handling two different pages with the same URL -
i'm working on program automatically logs site using selenium. in situations, if site doesn't remember browser, ask answer secret question before takes password page. thought handle if
statement checks current url against specific url knew produced when directed secret question page. issue i'm running into, url secret question page, , url password page same. there way differentiate these 2 pages url in situation, or need find alternative method?
if urls same, won't have differences compare, won't able tell page content based on url.
it's common have 1 page, 1 url, shows different content, determined backend code selenium can't see. need compare different between 2 pages, such element appears on 1 page.
presuming don't care whether password or secret question shown, want selenium through login process, easy solution use if / else statement check form appears , attempt fill out form present.
if ($this->iselementpresent($password_form)) { // enter password; } elseif ($this->iselementpresent($secret_question)) { // answer secret question; } else { throw new exception('could not find password form or secret question on login page. [url]'); }
the actual form element has different id or name each form can use identification, or input password/secret answer have different names. (if else fails, can text on page says whether enter password or secret question.)
Comments
Post a Comment