Home Upgrade Search Memberlist Extras Hacker Tools Award Goals Help Wiki Contact

C 

Selenium variable sendkeys

Hi,

So I'm trying to use xpath to find a specific number on a page and this to relay on the send function.

Code
var woodmarketread = drv.FindElement(By.XPath("//*[@id=\"premium_exchange_stock_wood\"]"));
            var woodmarketinput = drv.FindElement(By.XPath("//*[@id=\"premium_exchange_buy_wood\"]/div[1]/input"));

            woodmarketinput.SendKeys(woodmarketread);

How could I make this work?
Use .getText() or .getAttribute(String attr) on woodmarketread to get the right value.

Next do .SendKeys(woodmarketread) on woodmarketinput to fill in the value and compelete with a .SendKeys(Keys.Return) on woodmarketinput or click on the appropriate button.
(Jan 15, 2021 02:58 PM)Exalted Wrote:  Use .getText() or .getAttribute(String attr) on woodmarketread to get the right value.

Next do .SendKeys(woodmarketread) on woodmarketinput to fill in the value and compelete with a .SendKeys(Keys.Return) on woodmarketinput or click on the appropriate button.

Yep this worked. Cheers, had to convert var to string though.

Looks like this now:
Code
var woodmarketread = drv.FindElement(By.XPath("//*[@id=\"premium_exchange_stock_wood\"]")).Text;
var woodmarketinput = drv.FindElement(By.XPath("//*[@id=\"premium_exchange_buy_wood\"]/div[1]/input"));
woodmarketinput.SendKeys(Convert.ToString(woodmarketread));


Possibly Related Threads...
Thread / Author Replies Views Last Post
[Python] by Luffy-_-Aug 20, 2023 02:06 AM 12 445 Aug 20, 2023 02:06 AM
Last Post: Lucky4L
[Python] by Don CezarAug 20, 2023 01:37 AM 5 496 Aug 20, 2023 01:37 AM
Last Post: Lucky4L
by darkfantaOct 22, 2022 11:14 AM 6 364 Oct 22, 2022 11:14 AM
Last Post: darkfanta