HTML CODE:
<tr>
<td>
Filename:
<br>
<input type="file" size="35" name="filename">
<input type="hidden" value="Hidden Field Value" name="hiddenField">
</td>
</tr>
In Chrome this field looks as a button with label as choosefile. I am trying to click that button to attach file, but i could not able to. Trying to use the attachfile command as well.
No luck. Can any one let me know how to resolve this?
Thanks
Chandra
Chrome has inbuilt security restrictions which doesnt allows you to specify the uploaded file via javascripts. So sadly, there is no workaround for this issue.
Related
Below is the HTML snippet I am trying to get xpath. I have tried so many combination in chrome dev tools but no luck. Chropath message is that element might be from different src.
I am not sure what it means. Any help appreciated.
<input type="text" class="sn-global-typeahead-input -global-active-input" name="sncwsgs-
typeahead-input" id="sncwsgs-typeahead-input" placeholder="Search Global" autocomplete="off"
aria-label="Search" aria-hidden="false" aria-expanded="true" aria-activedescendant="sncwsgs-
typeahead-record-1-2" aria-autocomplete="both" aria-owns="sncwsgs-typeahead-sections" aria-
controls="sncwsgs-typeahead-sections" aria-describedby="sncwsgs-typeahead-instructions" aria-
haspopup="listbox" value="" role="combobox">
There's an id tag, so you can use the following for the XPath:
"//input[#id='sncwsgs-typeahead-input']"
That also translates to the following CSS Selector:
"input#sncwsgs-typeahead-input"
But if that's inside an iframe, you'll need to switch to the iframe first before you can interact with elements inside of it.
Learn about switching into iframes here: https://www.selenium.dev/documentation/webdriver/interactions/frames/
Example of switching into an iframe:
driver.switch_to.frame("iframe")
I have made a custom module for odoo 8 that adds a photogallery on the website. The user can then add images and descriptions from the backend that will be automatically displayed in the frontend.
Is there a way to translate texts efficiently in odoo that is added "dynamically" by the user such as image descriptions or product descriptions?
My idea is that the visitor can change language in the frontend and the correct translation should then be displayed next to the image.
Or do I need to have a description field in the backend for each language that I want support for?
EDIT:
The gallery is implementedd like this at the moment
<t t-foreach="photos" t-as="photo">
<table style="width:90%" align="center">
<tr>
<td style="width:60%;"> <span t-field="photo.image" t-field-options='{"widget": "image"}' /> </td>
<td style="width:40%; vertical-align:top;" >
<font size="4" face="Comic Sans MS">
<u><t t-esc="photo.name"/></u><br></br>
<t t-esc="photo.description" />
</font>
</td>
</tr>
</table>
</t>
Is there a way to translate the content of the photo.description field and not just only the name?
It should be enough to make the description fields translatable in the backend. Just add translate=True to the field definitions. I don't know how you've added the gallery, but if it was done correctly, multi language support should work with users that are logged in! All other website users (without login) should see the website in default language.
In my testcase i have the next locater:
Double Click Element //input[#value='user1']
The locater is for the next snippet:
<tr onselectstart="listview_onselectstart(this, event)" tabindex="1" class="row altrow selected"><input class="text" type="text" tabindex="-1" readonly="readonly" style="width:;" value="user1">
This works perfect with Chrome and Firefox. When i try this with ie i see the page refresing and nothing happends.
Doesnt ie works with javascript ? Or what can be the problem ?
IE has a long-standing history of extremely poor performance when it comes to XPath selectors.
Please consider using CSS selectors if you intend to work with IE.
In your case, Double Click Element css=input[value=user1] should do the trick.
I have to click on the button which has id. But this id is generated dynamically. And find By.className() is not doing anything.
The HTML code for the button:
<td class="x-btn-mc">
<em class="" unselectable="on">
<button id="cq-gen372" class=" x-btn-text" type="button">OK</button>
</em>
</td>
How to select the button and click on it in Java?
By.className() really was bugged in IE and some older Selenium versions. I didn't know it is still the case. Anyway! You can search by a lot of things, not just id:
You can try By.xpath("//button[text()='OK']"); if it is the only (or the first) OK button on page.
For more xpaths, see XPath v1.0 on w3.org and XPath v2.0 on w3.org - only for some new browsers!.
Or you can go with css selectors - The w3 again or wikipedia.
You can go with below options
//button[text()='OK']
xpath=//button[contains(., 'OK')]
//button[contains(#class, 'x-btn-text')]
i want to use selenium to click on a specific button !
the send button on gmail, the standard version and not the basic html version
i tried
<tr>
<td>selectFrame</td>
<td>c16nfgbb415qzj</td>
<td></td>
</tr>
<tr>
<td>clickAndWait</td>
<td>//div[#id=':v9']/b</td>
<td></td>
</tr>
didnot work
give me python code please and not html
Thanks
You can't record a script in Selenium and play it back using standard Google Mail. Most of the HTML names/IDs/classes in standard Google Mail are unpredictable.
You'd have to use xpath-based targets with indices e.g. //div[2]/div/div[3]. This has a high-dependency on the structure of the HTML being served by Google Mail. As soon as it changes, you'll need to modify your script.
The basic HTML version is predictable enough to just record and replay a script. You didn't say why you don't want to use that.