I am trying to use RSelenium to navigate with Firefox. I need to change an option button in about:config page for parameter browser.helperApps.neverAsk.saveToDisk. With RSelenium I am able to find the element I need to modify, but then I cannot find a way to update the value.
This is my HTML string to find
<tr class=""><th scope="row">browser.<wbr>helperApps.<wbr>neverAsk.<wbr>saveToDisk</th><td class="cell-value"><form id="form-edit"><input type="text"></form></td><td class="cell-edit"><button data-l10n-id="about-config-pref-save-button" class="primary button-save" title="Salva" form="form-edit"></button></td><td class="cell-reset"></td></tr>
I am using
go4 = rsc$findElement(using = "xpath", value = "//th[substring-after(normalize-space(string(.)),': ')=browser.helperApps.neverAsk.saveToDisk']")
but the error I get is
Summary: NoSuchElement
Detail: An element could not be located on the page using the given search parameters.```
How can I find the element and change the default value?
Thank you
Related
i got stuck 4 hours ago and i cant figure this out, how can i make the balance to go from 0.13 to $50.13?
Here is the code:
<li class="notranslate" id="Mata" translate="no">
Balance: $0.13</li>
Im trying to do this using the console in google chrome
If you set an id on the link like this:
<a id="link" href="/wallet">Balance: $0.13</a>
Then you can use:
document.getElementById("link").innerHTML = "Balance: $50.13";
If you are not able to set an id then you can do:
document.querySelector("link[href='/wallet']").innerHTML = "Balance: $50.13";
The chrome inspect tool also has a feature where if you click the icon in the top-left of the tool, it will let you select an element from the page. After selecting an element, you can refer to it in the console as $0. So you after selecting the link you could do:
$0.innerHTML = "Balance: $50.13";
Since you do not have an id assigned to your a tag, you can use document.querySelectorAll, which will return a list of elements that match the specified selector.
Then, you can access each element using its index number, which in your case is 0, since you have only one element.
To change the text, simply use the text property:
document.querySelectorAll("a[href='/wallet']")[0].text = "Balance: $50.13";
I am using Python 2.7, Webdriver and Chrome. Manually, I can mouse swipe across text containing a hyperlink on a web page and copy it to the clipboard. How do I do this automatically? I have no issue finding the element containing the hyperlink. I am not trying to find the hyperlink. I am trying to paste it into a web page text box which does not process https://www.python.org/ ">Link within an "a" tag but processes it correctly when pasted from elsewhere i.e. "Link" with embedded href.
Even after OP clarifications, it's still hard to understand the exact issue, so I'll try to cover all possible options :)
Suppose we have an anchor element, like Link
We can find this element in such ways
element = driver.find_element_by_xpath('//a[text()="Link"]')
element = driver.find_element_by_xpath('//a[#href=" python.org "]')
depending on what information we currently know about the element and what exactly we want to scrap.
Also, we can use index of anchor element element = driver.find_elements_by_tag_name('a')[0]
1) To get value of href attribute:
value = element.get_attribute('href')
Output: https://python.org
2) To get value of text node:
value = element.text
Output: "Link"
3) To get complete HTML code of element:
value = element.get_attribute('outerHTML')
Output: Link
I want to create a new tabbed panel for the Dojo tab container using CSJS like:
dijit.byId('#{id:djTabContainer1}').createTab({ tabTitle: Math.random()});
The default tab panel has an panel that will use the iframe tag and I want to pass in the above call the src html attribute to the panel.
Question : I can specify a url to load in the iframe. Is there a way to pass this?
It seems like the createTab only does certain tab related parameters like action and tabTitle.
Howard
The syntax is somewhat obscure here. Starting with the code in the ExtLib demo app:
XPagesExt.nsf/Core_DynamicTabs.xsp
Change the script in button4 to:
dijit.byId('#{id:djTabContainer1}')
.createTab({
"newName":'Tab'+Math.random(),
"newHref":'/XPagesExt.nsf/page5.xsp'})
to match the syntax you're requesting.
And, in the tab that's referenced by defaultTabContent, change the title and href to use those passed URL parameters:
<xe:djTabPane xp:key="doc" id="djTabPane2"
title="${javascript:/*load-time-compute*/param.newName}"
href="${javascript:/*load-time-compute*/param.newHref}"
It will create the tab and will attempt to load the href contents. I'm not seeing it as an iframe though - it's just a container div.
I'm trying to test my GWT application using selenium, the html generated by GWT Textbox is shown as below:
<input type="text" class="gwt-TextBox" >
No value there, but from UI i can see the text, Is there a way to get the value from selenium?
UPDATE: I can locate the input from selenium, but can not get its value, for example the value of above input is "blahblah...", which i can see from page UI, but can't get from the above html.
#Bhumika is correct, having a unique id attribute for every element you would want to manipulate is good programming practice. But if you don't have that and can't get it added, you still have a good handle on this particular case: the placeholder attribute. To locate the element, use the XPath //input[#placeholder='Input note title...']. To obtain the value of the field, get its value attribute.
Like #BMT said, you should get the value using getAttribute, like this
GWT Code
TextBox textField = new TextBox();
textField.ensureDebugId("textFieldId");
Selenium Code
driver.findElement(By.id("textFieldId")).getAttribute("value");
You could see all the properties (visible or invisible) of one element using Inspect Element Tool of browsers (F12), then get the value you want.
Each widget should have a id for selenium testing. Here selenium does not identify element, and you are not able to get value which are on UI. so you have to set id for input widget.
i.e
TextBox textField= new TextBox();
textField.getElement().setId("name");
If you want the resulting DOM to look like
<input type="text" class="gwt-TextBox" value="myValue">
you'll have to use
textBox.getElement().setAttribute("value", "myValue");
instead of
textBox.setText("myValue")
That's because setText will only update the value property (i.e. theDomElement.value = "myValue"), which will not update the value attribute (i.e. <input value="myValue"/>).
When updating a property, the browser will not update the associated attribute.
I'm using Selenium for making some work: script should click at link followed by it's own address. For example, there is a method: clickAndWait. I have to pass it link title. But at my page this title changes, so I have to pass address to click at.
Could you help me with this?
p.s. I asked this question in selenium group, but still have no answer.
upd: For exampe, I have such html-code:
Some changeable title
Some changeable title
And selenium pseudocode:
ClickAndWait('Some changeable title')
But I have to click at site 'another.com', not 'lalala.com'. And link's title changes every time. Only link address is the same.
You could use one of the following locators:
//use XPath to match links with full href value
selenium.clickAndWait("//a[#href='another.com']");
//use XPath to match links with href values that start with string
selenium.clickAndWait("//a[starts-with(#href,'another.com')]"); //use partial href value
//use XPath to match links with href values that contain string
selenium.clickAndWait("//a[contains(#href,'another.com')]"); //use partial href value