Bumping this from two months ago since I have not found a solution. I am using Firefox driver to find and then click on a hyperlink named "Inbox" but after exhaustive attempts, Selenium still can't find the element. Any help would be appreciated as I genuinely have not been able to find a reason why Selenium webdriver cannot find the element.
In the below HTML code, I have considered that there might be a frame but none can be found; if someone could confirm that there in fact is no iframe in the below code that would be appreciated! I also already have a time.sleep(40) in my script to allow for enough time for webdriver to find the element. So I am running out of ideas, but was thinking that maybe the #text element ("  ") right before the "inbox" hyperlink element might be causing the issue by hiding the "inbox" element? Any tips on how to proceed would be appreciated; all my attempts at resolution are listed below.
Below is my code up until this element issue comes up (URL has been removed as it is proprietary):
from selenium import webdriver
import time
driver = webdriver.Firefox()
driver.get("[URL REMOVED]")
time.sleep(2)
elem1 = driver.find_element_by_css_selector('#main-content > div > div.col-md-4.radix-layouts-sidebar.sidebar-right.panel-panel.sidebar > div > div.panel-pane.pane-entity-field.pane-it-service-field-related-services.block > div > div > ul > li:nth-child(1) > a')
elem1.click()
#Logging in
time.sleep(40)
#Now in the System, click on Inbox Button
elem2 = driver.find_element_by_??? # Trying to figure out this code to find inbox element
elem2.click()
I have tried the below in trying to find the element :
find_element_by_xpath('//td[#class=’MENUCHOICE’]//a[#href="main.do?action=inbox"]')
find_element_by_xpath('/html/body/table/tbody/tr[6]/td/a')
find_element_by_link_text('Inbox')
find_element_by_partial_link_text('Inb')
find_element_by_css_selector('body > table > tbody > tr:nth-child(6) > td > a')
find_element_by_css_selector("td.MENUCHOICE a[href='main.do?action=inbox']")
All the locators I have tried raise 'selenium.common.exceptions.NoSuchElementException: Message: no such element: Unable to locate element'
I cannot provide the link to the page as it's proprietary, but below I have provided the page HTML in case someone can assist (The element of interest is under the second to last MENUCHOICE class: Inbox):
<html>
<!--702.15-->
<head>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
<meta http-equiv="Cache-Control" content="no-cache">
<meta http-equiv="Expires" content="0">
<meta http-equiv="Pragma" content="no-cache">
<title>UDM - Notification System</title>
<style type="text/css">
td.MENU1 {
FONT-FAMILY: Verdana, Arial, Helvetica, sans-serif;
FONT-SIZE: 18pt;
FONT-WEIGHT: medium;
color: navy;
}
td.MENU2 {
FONT-FAMILY: Verdana, Arial, Helvetica, sans-serif;
FONT-SIZE: 15pt;
FONT-WEIGHT: medium;
color: navy;
}
td.MENUCHOICE {
FONT-FAMILY: Verdana, Arial, Helvetica, sans-serif;
FONT-SIZE: 14pt;
FONT-WEIGHT: medium;
color: blue;
}
</style>
</head>
<body bgcolor="#ffffff" background="payadm/images/background.gif">
<table width="750" border="0">
<tbody>
<tr>
<td><img height="55" width="129" src="payadm/images/udm_cw100.gif"></td>
</tr>
<tr>
<td> <img src="payadm/images/footerline.gif"></td>
</tr>
<tr>
<td class="MENU1"> AN Main Menu</td>
</tr>
<tr>
<td> </td>
</tr>
<tr>
<td class="MENUCHOICE"> Notification Functions:</td>
</tr>
<tr>
<td class="MENUCHOICE">
Inbox
</td>
</tr>
<tr>
<td class="MENUCHOICE">
Notification Selection
</td>
</tr>
Thanks for the help.
To click the element with text as Inbox you can use either of the following solutions:
css_selector:
find_element_by_css_selector("td.MENUCHOICE a[href='main.do?action=inbox']")
xpath:
find_element_by_xpath("//td[#class='MENUCHOICE']//a[#href='main.do?action=inbox' and contains(.,'Inbox')]")
This issue was resolved a month ago. It turns out that for this particular web application, Selenium webdriver needed to have a direct link from the get-go; otherwise it would not "recognize" the page it was on. This web app is usually not linked to directly; you usually go through an intermediary page that has the link posted.
I resolved this by directing Selenium to the web application directly instead of going through the intermediary page first and clicking on the web app link. I.e.:
from selenium import webdriver
import time
driver = webdriver.Firefox()
driver.get("[DIRECT LINK INSTEAD OF INTERMEDIARY PAGE LINK]")
Hope this helps anyone with a similar issue in the future.
Related
I am very new to Selenium so any help would be appreciated! I am trying to click the button "continue" in this page and it kept showing me:
"NoSuchElementException: no such element: Unable to locate element: {"method":"css selector","selector":"[id="bktContinue"]"}".
How do I get it to click "continue"?
Code trials:
url="https://www.exteriores.gob.es/Consulados/toronto/en/ServiciosConsulares/Paginas/Consular/Visados-Schengen.aspx"
driver.get(url)
continue_link = driver.find_element(By.PARTIAL_LINK_TEXT, 'HERE')
continue_link.click()
driver.implicitly_wait(15)
l=driver.find_element(By.ID,'bktContinue')
Snapshot of the HTML:
Here's the HTML I want it to click on:
<div id="dialog-confirm" title="Important Notice / Important Notice" style="font-size: 15px; background-color:#F3F5F7; height: 100%; width: 94%; box-sizing: border-box; color:black !important;">
<div style="text-align: center;">
<span style="color: #ff0000; font-weight: bold;"><font style="vertical-align: inherit;"><font style="vertical-align: inherit;">ATTENTION READ THIS MESSAGE CAREFULLY</font></font></span>
</div>
<br>
<div style="text-align: justify;">
<div style="text-align: justify;"><font style="vertical-align: inherit;"><font style="vertical-align: inherit;">
• Enter the data requested, correct and complete. </font></font><br>
<br><font style="vertical-align: inherit;"><font style="vertical-align: inherit;">
• Do not use initials for the identifying fields or we will reject your request. </font></font><br>
<br><font style="vertical-align: inherit;"><font style="vertical-align: inherit;">
• </font></font><span style="text-decoration: underline"><font style="vertical-align: inherit;"><font style="vertical-align: inherit;">The request for a minor's passport renewal must be made with the minor's passport data. </font></font></span><br>
<br><font style="vertical-align: inherit;"><font style="vertical-align: inherit;">
• The information you provide is the one that will appear in the passport. </font><font style="vertical-align: inherit;">Pay attention. </font></font><br>
<br><font style="vertical-align: inherit;"><font style="vertical-align: inherit;">
Those appointments with incomplete or incorrect data will be canceled by the system. </font></font><br><font style="vertical-align: inherit;"><font style="vertical-align: inherit;">
A person whose identity cannot be verified will not be able to access the facilities, having to request a new appointment with correct identification data.</font></font><br>
<br>
</div>
<br>
<div style="text-align: justify; font-weight: bold;"><font style="vertical-align: inherit;"><font style="vertical-align: inherit;">
CONTINUING CONSTITUTES ACCEPTANCE OF THE ABOVE INDICATED RULES.
</font></font></div>
</div>
<br>
<div id="bktContinue" style="text-align: center;">
<div style="color: #ffffff; padding: 5px 10px; background-color: #99cc00; display: inline-block;"><font style="vertical-align: inherit;"><font style="vertical-align: inherit;">
CONTINUE
</font></font></div>
</div>
Snapshot of the element:
This is what I currently have. To get to the website I am having trouble with, you have to go in this website first:
https://www.exteriores.gob.es/Consulados/toronto/en/ServiciosConsulares/Paginas/Consular/Visados-Schengen.aspx
Then click "book your appointment here"
How do I get it to click "continue" after this?
Try using this CSS selector instead:
continue_div = driver.find_element(By.CSS_SELECTOR,'#bktContinue > div')
My assumption is that the reason the continue button is not being pressed, is because the real element that should be clicked is the div inside of the element with the ID bktContinue.
Also another tip: It's possible that you're not clicking the correct link at this line:
continue_link = driver.find_element(By.PARTIAL_LINK_TEXT, 'HERE')
continue_link.click()
Because you're looking for a link element that contains the text 'HERE', there are 4 elements that match this criteria, so your scriptelement might be clicking another link where the #bktContinue is not on the next page and this might also be leading to a NoSuchElementException.
To click on the element with text as CONTINUE you need to induce WebDriverWait for the element_to_be_clickable() and you can use either of the following locator strategies:
Using CSS_SELECTOR:
WebDriverWait(driver, 20).until(EC.element_to_be_clickable((By.CSS_SELECTOR, "div#bktContinue font"))).click()
Using XPATH:
WebDriverWait(driver, 20).until(EC.element_to_be_clickable((By.XPATH, "//div[#id='bktContinue']//font[contains(., 'CONTINUE')]"))).click()
Note: You have to add the following imports :
from selenium.webdriver.support.ui import WebDriverWait
from selenium.webdriver.common.by import By
from selenium.webdriver.support import expected_conditions as EC
I am trying to get the value form an input field that is in an iframe. I switched to the iframe but the program is still unable to find the element, so a time out exception is raised. I am using the internet explorer web driver and I can not use any other driver because the website only works in internet explorer.
The code I use:
browser = webdriver.Ie()
browser.get('http://www.thewebsite.com')
wait = WebDriverWait(browser, 10)
wait.until(EC.frame_to_be_available_and_switch_to_it((By.ID, 'Content')))
MRR = wait.until(EC.element_to_be_clickable((By.XPATH, "//INPUT[#id='txtTotalMonthlyCharge']"))).get_attribute('value')
I already tried increasing the wait time and also locationg by ID
The HTML:
<iframe id="Content">
<html>
<head>
</head>
<body style="margin-left: 0; margin-top: 0; overflow:hidden">
<form name="frmServicesTree" method="post" action="ServicesTree.aspx?AccountNo=50084779&pageID=SERVICESTREE" id="frmServicesTree">
<table>
<tr>
<td class="flowLabel" width="140px"><span id="txtTotalMonthlyChargelabel" style="width:95%;height:17px;">Total Monthly Charge</span></td><td class="flowReadOnly"><input name="txtTotalMonthlyCharge" id="txtTotalMonthlyCharge" type="text" readonly="" tabindex="-1" value="JA$11,199.00" style="vertical-align:top;width:100%;" /></td>
</tr>
</table>
</body>
</iframe>
I'm currently using Odoo 12.0+e-20181025. I have changed the logo for the email but the GMail that has received the previous email refused to show the new logo although the link of the image in the email has pointed to the new logo.
I have checked the image and it is the correct image. I've also tried following the URL in the email that showed the previous (the wrong) image, and it led to a correct image, just not showing it in the email display.
I've read that it has something to do with the Gmail image caching function, but since most of my users are using Gmail, I need to make it so that the image won't cache and my idea at the moment is to add no-cache at the header HTML, but I don't know where can I set that in my current version of Odoo.
Thank you for reading and for your help.
Okay, I found the answer. It is in the view > mail_notification_light
Here are the first few lines of codes in the XML
<?xml version="1.0"?>
<t t-name="mail.mail_notification_light">
<table border="0" cellpadding="0" cellspacing="0" style="padding-top: 16px; background-color: #F1F1F1; font-family:Verdana, Arial,sans-serif; color: #454748; width: 100%; border-collapse:separate;"><tr><td align="center">
<table border="0" cellpadding="0" cellspacing="0" width="590" style="padding: 24px; background-color: white; color: #454748; border-collapse:separate;">
Then changed into these.
<?xml version="1.0"?>
<t t-name="mail.mail_notification_light">
<meta http-equiv="Cache-control" content="no-cache" />
<table border="0" cellpadding="0" cellspacing="0" style="padding-top: 16px; background-color: #F1F1F1; font-family:Verdana, Arial,sans-serif; color: #454748; width: 100%; border-collapse:separate;"><tr><td align="center">
<table border="0" cellpadding="0" cellspacing="0" width="590" style="padding: 24px; background-color: white; color: #454748; border-collapse:separate;">
So I put the in there. So far, it works wonder. Once again, thank you for everyone that has been reading and giving comment.
Edited based on the answers:
I am using Selenium with Python and trying to locate a button on an web application on Chrome. The block of code has an iframe as mentioned in the answer.
<iframe data-bind="attr: { src: src, foo: $root.registerTargetDisplayFrame($data, $element) }, event: {load: function() {loaded(true);}, focus: $root.blurredNavigationPane}" src="https://products.com/InfoShareAuthor/home">
<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Frameset//EN" "http://www.w3.org/TR/html4/frameset.dtd">
<html>
<head>code here
<frameset id="IshTop" class="infoshareauthor" framespacing="0" border="0" bordercolor="#FFFFFF" frameborder="0" rows="31,25,*,0">
<frame id="MenuBar" scrolling="no" name="MenuBar" src="./MainMenuBar.asp">
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html>
<head>
<body>
<div id="Top-Menu-Container">
<div id="top-menu-wrapper">
<div id="top-menu">
<form name="MainBar">
<script type="text/javascript" language="javascript">
<table cellspacing="0" cellpadding="0" border="0">
<tbody>
<tr>
<td width="95" valign="bottom">
<td width="95" valign="bottom">
<div style="POSITION: relative;">
<div height="30" style="POSITION: absolute; z-index:0; top: 4px; margin-left: -5px">
<a href="javascript:TabSelect(1);">
<img border="0" src="./UIFramework/tab_active.png">
</a>
</div>
<div onclick="javascript:TabSelect(1);" style="POSITION: absolute; z-index:2; top: -8px">
<table cellspacing="0" cellpadding="0" border="0">
<tbody>
<tr>
<td id="MenuButton1" class="tab_active" width="95" valign="bottom" height="30" align="center" style="cursor:pointer;padding-bottom:2px;" name="Repository">Repository</td>
</tr>
</tbody>
</table>
</div>
</div>
</td>
<td width="95" valign="bottom">
<td width="95" valign="bottom">
<td width="95" valign="bottom">
<td width="95" valign="bottom">
</tr>
</tbody>
</table>
</form>
</div>
<div id="top-help">
<div id="top-nav-links">
</div>
</div>
</body>
</html>
</frame>
<frame id="BreadCrumbs" frameborder="0" border="0" scrolling="no" name="BreadCrumbs" src="./BreadCrumbs.asp">
<frameset id="Application" bordercolor="#0099CC" frameborder="0" rows="0,*,0,0,0,0">
<frameset id="HiddenFrameSet" bordercolor="#0099CC" frameborder="0" rows="0,0,,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1">
<noframes> It looks like your browser doesn't support frames. This page requires frames in order to function. <br><br>For more information, please <a href='http://www.trisoftcms.com/en/contact-us.html' target=_blank style='white-space:nowrap'>contact us</a>. </noframes>
</frameset>
</html>
</iframe>
I switched frames using this:
iframe = browser.find_element_by_xpath("//iframe[#src='https://products.com/InfoShareAuthor/home']")
browser.switch_to.frame(iframe)
The code that I wrote:
browser.find_element_by_xpath("//td[#id='MenuButton1'][#name='Repository'][contains(text(),'Repository')]")
I could find the element using this xpath when I did a Firebug search
I also tried:
browser.find_element_by_id("MenuButton1")
and
browser.find_element_by_name("Repository")
Note: When I click the button, the URL does not change. Just a list of items in the application expands. Also, IDs and the Names are unique for the seven five menu buttons. None of the menu buttons work.
Does any one have any idea about what might be wrong? I am very new to Python and Selenium.
This doesn't exactly answer your question, but it does address what you're trying to do: it is likely you can accomplish the same task (and many others) with SDL's API client ISHRemote.
https://github.com/sdl/ISHRemote
For example, if you're looking for all the directories under '\General':
Import-Module ISHRemote
# first authenticate
$session = New-IshSession -IshPassword $password -IshUserName $username -WsBaseUrl 'https://ccms.example.com/InfoShareWS/'
# get a list of all the child folders under General
Get-IshFolder -IshSession $session -FolderPath '\General' -Recurse -Depth 2
Or if you're trying to get a list of files in a particular directory:
Import-Module ISHRemote
# first authenticate
$session = New-IshSession -IshPassword $password -IshUserName $username -WsBaseUrl 'https://ccms.example.com/InfoShareWS/'
# get all content in this folder
Get-IshFolderContent -IshSession $session -FolderPath 'General\path\to\topics'
With ISHRemote, you can also find and update publications, move content, modify metadata, etc.
Hope that helps.
you can try load iframe url. It avoids issues with selenium waiting from the iframe to load
I am trying to type 8 to cell by using friday.send_keys(8) but it doenst type number, and I dont get any error on my script too.
I can see my click is working, but send_keys is not working. I have tried multiple ways, and I have look all other SO question on this nothing really helped.
I downgrade my Firefox to 28
Selenium Version 2.53.6
cursor looks like
friday = driver.find_element_by_xpath("//td[#class=' x-grid-cell x-grid-cell-gridcolumn-1111 ']")
time.sleep(5)
friday.click()
friday.send_keys(8)
HTML element
<td class="x-grid-cell x-grid-cell-gridcolumn-1111">
<div class="x-grid-cell-inner" style="text-align: center; ;"></div>
</td>
IF you click on cell and do inspect html element adds <input>
<td id="textfield-1134-bodyEl" class="x-form-item-body" role="presentation" colspan="3" style="width: 100%;">
<input id="textfield-1134-inputEl" class="x-form-field x-form-text" type="text" autocomplete="off" name="03/03/2017" aria-invalid="false" data-errorqtip="" style="-moz-user-select: text; width: 100%;"></input>
Problem solver by:
friday_time = driver.find_element_by_name("03/03/2017")
friday_time.send_keys(8)
friday_time.send_keys(Keys.ENTER)
Thank you
#WillemVanOnsem